Simple Database using MongoDB
The name is a copy of quick.db
, this uses the Mongo Atlas Database to store data though
new database(mongo url, options)
Parameter |
Type |
Optional |
Description |
Mongo URL |
URL |
✖ |
The URL given to you by the MongoDB Atlas Connection |
options |
Object |
null |
null |
options.name |
String |
✖ |
The name of the collection you want to create |
const quickMongo = require('@turph/quickmongo');
const database = new quickMongo('{ INSERT MONGO URL HERE }', { name: 'database' });
db
.on('error', err => console.log(err))
.on('connected', info => console.log(info));
Constructor
Parameter |
Type |
Optional |
Description |
Key |
String |
✖ |
The key of the value |
Value |
String / Object |
✖ |
The value of the key you wish to set |
await database.set('foo', 'fee');
Returns Promise<Boolean>
Parameter |
Type |
Optional |
Description |
key |
String |
✖ |
The key of that vakue you wish to find |
await database.get('foo'); // fee
Returns Promise<String>
Parameter |
Type |
Optional |
Description |
query |
String |
✖ |
The term you wish to search for |
await database.search('foo');
Returns Promise<Object>
Parameter |
Type |
Optional |
Description |
query |
String |
✖ |
The term you wish to search for |
await database.find('foo');
Returns Promise<Object>
Parameter |
Type |
Optional |
Description |
|
|
|
|
Returns Promise<Object>
Parameter |
Type |
Optional |
Description |
Key |
String |
✖ |
The key of the value you wish to delete |
await database.delete('foo');
Returns Promise<Boolean>
Parameter |
Type |
Optional |
Description |
Key |
String |
✖ |
The key of the value you wish to clear from your database. Note: this will delete ALL matches so perform at your own risk |
await database.clear('foo');
Returns Promise<Boolean>