@chevre/domain
Version:
Chevre Domain Library for Node.js
59 lines (52 loc) • 2.19 kB
text/typescript
// tslint:disable:no-console
import * as moment from 'moment';
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 creativeWorkRepo = await chevre.repository.CreativeWork.createInstance(mongoose.connection);
const result = await creativeWorkRepo.upsertMoviesByIdentifier(
[
{
$set: {
id: '',
identifier: '20231215',
typeOf: chevre.factory.creativeWorkType.Movie,
duration: 'PT2H',
name: { ja: '名探偵コナン ゼロの執行人', en: 'Detective Conan Zero Enforcer' },
offers: {
typeOf: chevre.factory.offerType.Offer,
availabilityEnds: moment('2118-11-04T15:00:00.000Z')
.toDate(),
availabilityStarts: moment('2018-11-25T15:00:00.000Z')
.toDate()
},
project: { typeOf: chevre.factory.organizationType.Project, id: PROJECT_ID },
additionalProperty: [
{
name: 'posterImage',
value: 'https://iwiz-movies.c.yimg.jp/c/movies/pict/p/p/90/cb/174755_02.jpg'
}
],
// headline: 'サブタイトルサブタイトル',
datePublished: moment('2018-11-04T15:00:00.000Z')
.toDate(),
distributor: {
id: '5e35398a8067a30012dd6717',
codeValue: '001',
...{
distributorType: '001'
}
}
},
$unset: { headline: 1 }
}
],
{ replace: true }
);
console.log('result:', result);
}
main()
.then(console.log)
.catch(console.error);