UNPKG

1.01 kBJavaScriptView Raw
1/**
2 * アクション検索サンプル
3 */
4const moment = require('moment');
5const mongoose = require('mongoose');
6const domain = require('../');
7
8async function main() {
9 await mongoose.connect(process.env.MONGOLAB_URI);
10
11 const actionRepo = new domain.repository.Action(mongoose.connection);
12 const actions = await actionRepo.search({
13 sort: { startDate: -1 },
14 typeOf: domain.factory.actionType.AuthorizeAction,
15 startFrom: moment().add(-3, 'days').toDate(),
16 startThrough: moment().toDate(),
17 object: {
18 // typeOf: { $in: ['CreditCard'] }
19 },
20 // purpose: {
21 // id: { $in: ['5d3d6d3d8205a20019c1b5b0'] }
22 // },
23 result: {
24 // id: { $in: ['5d3d6d3d8205a20019c1b5b0'] }
25 }
26 });
27 console.log(actions.length, 'actions found.');
28
29 // await mongoose.disconnect();
30}
31
32main().then(() => {
33 console.log('success!');
34}).catch((error) => {
35 console.error(error);
36 process.exit(1);
37});