2018-03-03 11:39:56 +09:00
|
|
|
import { DatabaseConnectors } from '../connectors.js';
|
2018-02-11 12:57:51 +09:00
|
|
|
|
2018-03-03 11:39:56 +09:00
|
|
|
DatabaseConnectors.mongo = {
|
2018-02-18 15:27:25 +09:00
|
|
|
get: async (collection, selector = {}, options = {}) => {
|
|
|
|
return await collection.findOne(selector, options);
|
2018-02-11 12:57:51 +09:00
|
|
|
},
|
2018-02-18 15:27:25 +09:00
|
|
|
find: async (collection, selector = {}, options = {}) => {
|
2018-02-11 12:57:51 +09:00
|
|
|
return await collection.find(selector, options).fetch();
|
|
|
|
},
|
2018-02-18 15:27:25 +09:00
|
|
|
count: async (collection, selector = {}, options = {}) => {
|
2018-02-11 12:57:51 +09:00
|
|
|
return await collection.find(selector, options).count();
|
|
|
|
},
|
2018-02-18 15:27:25 +09:00
|
|
|
create: async (collection, document, options = {}) => {
|
2018-02-11 12:57:51 +09:00
|
|
|
return await collection.insert(document);
|
|
|
|
},
|
2018-02-18 15:27:25 +09:00
|
|
|
update: async (collection, selector, modifier, options = {}) => {
|
|
|
|
return await collection.update(selector, modifier, options);
|
2018-02-11 12:57:51 +09:00
|
|
|
},
|
2018-02-18 15:27:25 +09:00
|
|
|
delete: async (collection, selector, options = {}) => {
|
|
|
|
return await collection.remove(selector);
|
2018-02-11 12:57:51 +09:00
|
|
|
},
|
|
|
|
}
|