mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
more intermediary
This commit is contained in:
33
server/handlers/dbFunctions/create.js
Normal file
33
server/handlers/dbFunctions/create.js
Normal file
@@ -0,0 +1,33 @@
|
||||
var path = require("path");
|
||||
var mongojs = require("mongojs");
|
||||
var db = require(pathThumbnails + "/handlers/db.js");
|
||||
|
||||
async function collection(collection) {
|
||||
return new Promise((resolve, reject) => {
|
||||
db.createCollection(coll, function(err, docs) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
resolve(docs);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function index(collection, indexObject, extraObject) {
|
||||
return new Promise((resolve, reject) => {
|
||||
db.collection(collection).createIndex(indexObject, extraObject, function(
|
||||
err,
|
||||
docs
|
||||
) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
resolve(docs);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.collection = collection;
|
||||
module.exports.index = index;
|
||||
Reference in New Issue
Block a user