@chevre/domain
Version:
Chevre Domain Library for Node.js
62 lines (55 loc) • 2.34 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);
const PRICE = 1234;
// tslint:disable-next-line:max-func-body-length
async function main() {
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
const offerRepo = await chevre.repository.AggregateOffer.createInstance(mongoose.connection);
const result = await offerRepo.upsertByIdentifier(
[
{
additionalProperty: [],
addOn: [],
alternateName: { en: '', ja: '2024092601' },
availability: chevre.factory.itemAvailability.InStock,
availableAtOrFrom: [],
itemOffered: {
typeOf: chevre.factory.product.ProductType.EventService,
serviceOutput: {}
},
name: { ja: '2024092601', en: '2024092601' },
priceCurrency: chevre.factory.priceCurrency.JPY,
priceSpecification: {
name: { en: '2024092601', ja: '2024092601' },
price: PRICE,
priceCurrency: chevre.factory.priceCurrency.JPY,
referenceQuantity: {
typeOf: 'QuantitativeValue',
value: 1,
unitCode: chevre.factory.unitCode.C62
},
typeOf: chevre.factory.priceSpecificationType.UnitPriceSpecification,
valueAddedTaxIncluded: true,
accounting: {
typeOf: 'Accounting',
accountsReceivable: PRICE
}
},
settings: { ignoreCategoryCodeChargeSpec: false },
description: { en: '', ja: '' },
hasMerchantReturnPolicy: [],
identifier: '2024092601',
project: { typeOf: chevre.factory.organizationType.Project, id: PROJECT_ID },
typeOf: chevre.factory.offerType.Offer
}
]
// { replace: true }
);
// tslint:disable-next-line:no-null-keyword
console.dir(result, { depth: null });
}
main()
.then(console.log)
.catch(console.error);