Skip to content

Database

Jimmy Li edited this page Feb 11, 2020 · 4 revisions

Initialization

The database is split up into several modules. To get the full functionality, you should import the entire folder.

const db = require("./server/database");

The database functions are all promise based. In order to use them in the route handler, use async await:

const user = await db.auth.getUser({ id: "VALID-UUID-HERE" })

Authorization

This is the auth module.

db.auth.getUser({ id: "VALID-UUID-HERE" })
  .then(user => console.log(user))

User Object

All the functions return a user object, defined as such.

{
  id,          // uuid
  name,        // string
  email,       // string
  division,    // string
  password,    // string
  perms        // int
}

getUser

Returns the user associated with the given id.

Parameters: { id }

Returns: [User Object]: The associated user

makeUser

Creates a user given all the required parameters. Note that you need to pass in a valid uuid for id.

Parameters: [User Object]

Returns: [User Object]: The user that got created

updateUser

Updates the parameters of a user with a given id. Only the id parameter is required to be not undefined. If a parameter is undefined, that parameter will not be updated.

Parameters: [User Object]

Returns: [User Object]: The updated user

About rCTF

Installations and Deployment

Tutorials and Examples

Development

Clone this wiki locally