Skip to content
This repository was archived by the owner on Jan 11, 2019. It is now read-only.

Database Schemas and API Objects

Sebastian Mobo edited this page Oct 22, 2017 · 1 revision

Backend API Objects

Note that "ObjectIDs" refer to MongoDB Object IDs; usually, as 24-byte hex strings.

Item

Database

{
    "_id": <ObjectID>,
    "name": <String>,
    "count": <Integer>,
    "updated": <Date>,
    "created": <Date>
}

API

{
    "id": <ObjectID>,
    "name": <String>,
    "count": <Integer>,
    "reserved": <Integer>,
    "requested": <Integer>,
    "available": <Integer>,
    "created": <Date>,
    "updated": <Date>
}

Note that the "reserved", "requested", and "available" fields are all computed using data from the Reservations collection; they aren't actually stored on the database.

Reservation

API and Database

{
    "id": <ObjectID>,
    "part": <Item ObjectID>,
    "count": <Integer>,
    "requester": <User ObjectID>,
    "created": <Date>,
    "updated": <Date>
}

InventoryRequest

API and Database

{
    "id": <ObjectID>,
    "item": <Item ObjectID>,
    "requester": <User ObjectID>,
    "count": <Integer>,
    "status": "waiting" | "in_progress" | "delayed" | "fulfilled",
    "eta": <Date>,
    "created": <Date>,
    "updated": <Date>
}

Activity

API and Database

{
    "id": <ObjectID>
    "title": <String>,
    "description": <String>,
    "startTime": <Date>,
    "endTime": <Date>,
    "maxHours": <Postive, Non-Zero Number>,
    "userHours": [Array of Check-In Objects],
    "created": <Date>,
    "updated": <Date>,
}

Activity Check-In

API and Database

{
    "user": <User ObjectID>,
    "hours": <Number>,
    "checkIn": <Date> 
}

User

Database

{
    "_id": <ObjectID>,
    "username": <String>,
    "realname": <String>,
    "admin": <Boolean>,
    "activityCreator": <Boolean>,
    "disabled": <Boolean>,
    "passwordHash": <String: Base64-Encoded Hash>,
    "salt": <String>,
    "created": <Date>,
    "updated": <Date>,
}

API

{
    "id": <ObjectID>,
    "username": <String>,
    "realname": <String>,
    "admin": <Boolean>,
    "activityCreator": <Boolean>,
    "disabled": <Boolean>,
    "created": <Date>,
    "updated": <Date>,
}

For obvious reasons, user password hashes and salts aren't exposed to API clients.