@chevre/domain
Version:
Chevre Domain Library for Node.js
47 lines (40 loc) • 1.51 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);
// tslint:disable-next-line:max-func-body-length
async function main() {
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
const offerCatalogItemRepo = await chevre.repository.OfferCatalogItem.createInstance(mongoose.connection);
const result = await offerCatalogItemRepo.upsertManyByIdentifier(
[
{
$set: {
project: { typeOf: chevre.factory.organizationType.Project, id: PROJECT_ID },
typeOf: 'OfferCatalog',
id: '',
identifier: '2023122501CatalogItem',
itemListElement: [
{ id: '1001', typeOf: chevre.factory.offerType.Offer }
],
itemOffered: { typeOf: chevre.factory.product.ProductType.EventService },
name: {
en: 'xxx',
ja: 'xxx'
},
description: {
en: 'xxx',
ja: 'xxx'
},
additionalProperty: []
},
$unset: {}
}
]
// { replace: true }
);
console.log('result:', result);
}
main()
.then(console.log)
.catch(console.error);