Skip to contents

[Experimental]

MongoDB database don't enforce a structure to the documents contained within. Even though this is true, it's best to use this function explicitly, as after creation of collections it also create appropriate indexes for quick querying of the database by RegLogMongoConnector.

Usage

mongo_tables_create(
  mongo_url,
  mongo_db,
  mongo_options = mongolite::ssl_options(),
  account_name = "account",
  reset_code_name = "reset_code",
  user_data = NULL,
  hash_passwords = FALSE,
  verbose = TRUE
)

Arguments

mongo_url

URI to the MongoDB cluster

mongo_db

name of the MongoDB database

mongo_options

additional connection options such as SSL keys/certs

account_name

Name of the collection for storing user accounts credentials. Defaults to 'account'. Mandatory collection.

reset_code_name

Name of the collector for storing generated password reset codes. Defaults to 'reset_code'. Mandatory collection.

user_data

If you wish to import existing user database, you can input data.frame with that table in this argument. It should contain columns: username, password, email (ond optionally: create_time). Defaults to NULL.

hash_passwords

If you are importing table of users upon tables creation, you can also specify if the password should be hashed using scrypt::hashPassword. Defaults to FALSE. If you have unhashed passwords in imported table, set this option to TRUE.

verbose

Boolean specific if the actions made by function should be printed back to the console.

Details

Every document in created collections will have following structure:

  • account (default name)

    • username: character (index)

    • password: character

    • email: character (index)

    • create_time: timestamp

    • update_time: timestamp

  • reset_code (default name)

    • user_id: character (index)

    • reset_code: character

    • used: numeric

    • create_time: timestamp

    • update_time: timestamp

  • logs (default name, optional) - this collection isn't created with this function, as there is no need for that - MongoDB collections don't have a set structure, and no additional index is created there.

    • time: timestamp

    • session: character

    • direction: character

    • type: character

    • note: character

See also

Other RegLog databases: DBI_tables_create(), gsheet_tables_create()