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