@chevre/domain
Version:
Chevre Domain Library for Node.js
58 lines (46 loc) • 2.14 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) };
async function main() {
await mongoose.connect(<string>process.env.MONGOLAB_URI);
const acceptedOfferRepo = await chevre.repository.AcceptedOffer.createInstance(mongoose.connection);
let offerIds: string[];
// const searchConditions: chevre.factory.order.ISearchConditions = {
// limit: 10,
// page: 1,
// project: { id: { $eq: project.id } },
// orderNumbers: ['CIN1-3743286-2441943', 'CIN4-3943511-3323473'],
// acceptedOffers: { itemOffered: { typeOf: { $in: [chevre.factory.reservationType.EventReservation] } } }
// };
// let offerIds = await acceptedOfferRepo.__searchAcceptedOfferIds(searchConditions);
// console.log(offerIds);
offerIds = await acceptedOfferRepo.distinctValues(
{ orderNumber: { $in: ['CIN1-3743286-2441943', 'CIN4-3943511-3323473'] } },
'acceptedOffers.id'
);
console.log(offerIds);
const productIds = await acceptedOfferRepo.distinctValues(
{ orderNumber: { $in: ['CIN1-3743286-2441943', 'CIN4-3943511-3323473'] } },
'acceptedOffers.itemOffered.issuedThrough.id'
);
console.log(productIds);
const locationBranchCodes = await acceptedOfferRepo.distinctValues(
{ orderNumber: { $in: ['CIN1-3743286-2441943', 'CIN4-3943511-3323473'] } },
'acceptedOffers.itemOffered.reservationFor.superEvent.location.branchCode'
);
console.log(locationBranchCodes);
const offeredThroughIdentifiers = await acceptedOfferRepo.distinctValues(
{ orderNumber: { $in: ['CIN1-3743286-2441943', 'CIN4-3943511-3323473'] } },
'acceptedOffers.offeredThrough.identifier'
);
console.log(offeredThroughIdentifiers);
const invalidValues = await acceptedOfferRepo.distinctValues(
{ orderNumber: { $in: ['CIN1-3743286-2441943', 'CIN4-3943511-3323473'] } },
<any>'invalidValues'
);
console.log(invalidValues);
}
main()
.then()
.catch(console.error);