@chevre/domain
Version:
Chevre Domain Library for Node.js
194 lines (189 loc) • 8.78 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() {
const now = new Date();
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
const result = await eventRepo.upsertManyByAdditionalProperty(
{
events: [
{
additionalProperty: [
{
name: 'sampleCreateId',
value: 'akeuu512i-202410171410-01'
}
],
project: {
id: PROJECT_ID,
typeOf: chevre.factory.organizationType.Project
},
typeOf: chevre.factory.eventType.ScreeningEvent,
doorTime: new Date('2024-10-17T05:30:00.000Z'),
endDate: new Date('2024-10-17T05:45:00.000Z'),
eventStatus: chevre.factory.eventStatusType.EventScheduled,
// eventStatus: chevre.factory.eventStatusType.EventCancelled,
location: {
typeOf: chevre.factory.placeType.ScreeningRoom,
branchCode: '10',
name: {
ja: 'シネマ1',
en: 'CINEMA1'
},
address: {
ja: '7階',
en: '7F'
}
},
name: {
en: 'Ocean\'s Eight',
ja: 'オーシャンズ8'
},
offers: {
typeOf: chevre.factory.offerType.Offer,
// availabilityEnds: new Date('2024-09-15T11:45:00.000Z'),
// availabilityStarts: new Date('2024-09-01T15:00:00.000Z'),
eligibleQuantity: {
typeOf: 'QuantitativeValue',
unitCode: chevre.factory.unitCode.C62,
maxValue: 10
},
itemOffered: {
id: '6603a61f0c914b6c7fd18f99',
name: {
ja: 'アップロードテスト用(ムビチケあり)'
},
serviceOutput: {
typeOf: chevre.factory.reservationType.EventReservation,
reservedTicket: {
typeOf: 'Ticket',
ticketedSeat: {
typeOf: chevre.factory.placeType.Seat
}
}
},
typeOf: chevre.factory.product.ProductType.EventService,
availableChannel: {
typeOf: 'ServiceChannel',
serviceLocation: {
typeOf: chevre.factory.placeType.ScreeningRoom,
branchCode: '10',
name: {
ja: 'シネマ1',
en: 'CINEMA1'
},
containedInPlace: {
typeOf: chevre.factory.placeType.MovieTheater,
id: '5bfb841d5a78d7948369979a',
branchCode: '118',
name: {
ja: 'シネモーション赤坂 ',
en: 'CineMotion Akasaka'
}
}
}
},
serviceType: {
codeValue: '0001',
id: '64caf203c73a205ccefe80c5',
inCodeSet: {
typeOf: 'CategoryCodeSet',
identifier: chevre.factory.categoryCode.CategorySetIdentifier.ServiceType
},
typeOf: 'CategoryCode'
}
},
// validFrom: new Date('2024-09-01T15:00:00.000Z'),
// validThrough: new Date('2024-09-15T11:45:00.000Z'),
seller: {
typeOf: chevre.factory.organizationType.Corporation,
id: '59d20831e53ebc2b4e774466',
name: {
ja: 'シネモーション赤坂',
en: 'CineMotion Akasaka'
},
makesOffer: [
{
typeOf: chevre.factory.offerType.Offer,
availableAtOrFrom: { id: '51qbjcfr72h62m06vtv5kkhgje' },
availabilityEnds: now,
availabilityStarts: now,
validFrom: now,
validThrough: now
}
]
},
unacceptedPaymentMethod: [
'MovieTicket'
]
},
organizer: {
id: '59d20831e53ebc2b4e774466'
},
startDate: new Date('2024-10-17T05:30:00.000Z'),
superEvent: {
typeOf: chevre.factory.eventType.ScreeningEventSeries,
id: 'akeuu512i',
videoFormat: [
{
typeOf: '2D',
name: '2D'
}
],
soundFormat: [],
workPerformed: {
typeOf: chevre.factory.creativeWorkType.Movie,
identifier: '00002',
id: '5bfb841d5a78d79483699803',
name: {
en: 'Ocean\'s Eight',
ja: 'オーシャンズ8'
},
duration: 'PT1H50M'
},
location: {
typeOf: chevre.factory.placeType.MovieTheater,
id: '5bfb841d5a78d7948369979a',
branchCode: '118',
name: {
ja: 'シネモーション赤坂 ',
en: 'CineMotion Akasaka'
}
},
kanaName: '',
name: {
en: 'Ocean\'s Eight',
ja: 'オーシャンズ8'
},
additionalProperty: [],
startDate: new Date('2020-08-31T15:00:00.000Z'),
endDate: new Date('2030-01-01T15:00:00.000Z'),
description: {
en: '2018 United States crime movie.',
ja: '2018年のアメリカ合衆国の犯罪映画。'
},
headline: {
ja: '2018/12/14'
}
}
}
],
additionalPropertyFilter: { name: 'sampleCreateId' },
eventSeries: {
id: 'akeuu512i'
},
screeningRoom: {
branchCode: '10'
}
},
{ update: false }
);
// tslint:disable-next-line:no-null-keyword
console.dir(result, { depth: null });
}
main()
.then(console.log)
.catch(console.error);