UNPKG

@chevre/domain

Version:

Chevre Domain Library for Node.js

41 lines (33 loc) 1.38 kB
// 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, { autoIndex: false }); const offerCatalogItemRepo = await chevre.repository.OfferCatalogItem.createInstance(mongoose.connection); let result = await offerCatalogItemRepo.save({ project: { id: project.id, typeOf: chevre.factory.organizationType.Project }, typeOf: 'OfferCatalog', // id?: string; identifier: 'sample', name: { ja: 'sample', en: 'sample' }, description: { ja: 'sample', en: 'sample' }, itemListElement: [], itemOffered: { typeOf: chevre.factory.product.ProductType.EventService } }); console.log(result); result = await offerCatalogItemRepo.save({ project: { id: project.id, typeOf: chevre.factory.organizationType.Project }, typeOf: 'OfferCatalog', id: result.id, identifier: 'sample', name: { ja: 'sample', en: 'sample' }, description: { ja: 'sample', en: 'sample' }, itemListElement: [], itemOffered: { typeOf: chevre.factory.product.ProductType.EventService } }); console.log(result); } main() .then(console.log) .catch(console.error);