1.0.0 • Published 2 years ago
untitled_mongodb v1.0.0
Untitled Mongo
Initialization
Promises:
const mongo = require('untitled_mongodb');
const schema = [
{
name: 'collection',
model: new mongo.Schema({
username: {type: String, required: true},
password: {type: String, required: true},
created_at: {type: Date, default: Date.now},
updated_at: {type: Date, default: null},
}),
}
];
initialize('localhost', 'database', schema)
.then((models) => {...})
.catch((error) => console.log(error));
Async/await:
const mongo = require('untitled_mongodb');
const schema = [
{
name: 'collection',
model: new mongo.Schema({
username: {type: String, required: true},
password: {type: String, required: true},
created_at: {type: Date, default: Date.now},
updated_at: {type: Date, default: null},
}),
}
];
...
const models = await initialize('localhost', 'database', schema);
...
Function Usages
1.0.0
2 years ago