asmund
The best groups and users manager database module for microservices
Usage
Database Module
The database module contains all the methods for direct communication with postgres or the mysql database
const asmund = const options = database: 'asmund' username: 'root' password: 'mypass' host: 'localhost' dialect: 'postgres' pool: max: 10 min: 0 idle: 10000 const db = options db Or using callback db
API
db#setup([callback]): void
This method setup the database.
callback
(Function) this argument is optionalerr
(Object) if any
db
db#drop([callback]): void
This method setup the database.
callback
(Function) this argument is optionalerr
(Object) if any
db
db#saveUser(user, [callback]): User
This method save an user.
-
user
(Object)fullname
(String) user fullname.email
(String) user email.username
(String) user usernamepassword
(String) user passwordgroupId
(String) group id
-
callback
(Function) this argument is optionalerr
(Object) if anyuser
(Object) saved user
const user = fullname: 'The administrator' email: 'admin@app.com' username: 'admin' password: 'root' db Or using promise db
db#getUser(username, [callback]): User
This method find an user by username.
-
username
(String) user username -
callback
(Function) this argument is optionalerr
(Object) if anyuser
(Object) found user
db Or using promise db
db#getUsers([callback]): [User]
This method find all users.
callback
(Function) this argument is optionalerr
(Object) if anyusers
(Object) user list
db Or using promise db
db#updateUser(username, data, [callback]): User
This method update an user
username
(String)data
(Object)fullname
(String)email
(String)username
(String)password
(String)
callback
(Function) this argument is optionalerr
(Object) if anyuser
(Object) user created
const data = username: 'my_new_username' db Or using promise db
db#deleteUser(username, [callback]): User
This method delete an user
username
(String)callback
(Function)err
(Object)user
(Object)
db Or using promise db