@chevre/domain
Version:
Chevre Domain Library for Node.js
37 lines (28 loc) • 1.05 kB
text/typescript
// tslint:disable:no-console
import * as mongoose from 'mongoose';
import { chevre } from '../../../lib/index';
const project = { id: String(process.env.PROJECT_ID) };
mongoose.Model.on('index', (...args) => {
console.error('******** index event emitted. ********\n', args);
});
async function main() {
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
const indexes = await mongoose.connection.db.collection('authorizations')
.indexes();
// console.log(indexes);
console.log(indexes.length, 'indexes found');
const authorizationRepo = await chevre.repository.Authorization.createInstance(mongoose.connection);
const docs = await authorizationRepo.projectFields(
{
limit: 10,
project: { id: { $eq: project.id } }
// audience: { id: { $eq: '6749bd9b84c1b2a0759cbfc8' } }
},
['code']
);
console.log('docs found', docs);
console.log(docs.length, 'docs found');
}
main()
.then()
.catch(console.error);