Compare commits
2 commits
5d649a1e37
...
cde1fafacb
Author | SHA1 | Date | |
---|---|---|---|
Nicholai Nissen | cde1fafacb | ||
Nicholai Nissen | 9a3e0f2bcd |
|
@ -3,8 +3,8 @@ import { model, Schema, Document } from 'mongoose'
|
||||||
|
|
||||||
const ScriptSchema: Record<keyof IScript, any> = {
|
const ScriptSchema: Record<keyof IScript, any> = {
|
||||||
title: { type: String, required: true },
|
title: { type: String, required: true },
|
||||||
video: { type: String, required: true },
|
body: { type: String, required: true },
|
||||||
body: { type: String, required: true }
|
video: { type: String }
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ScriptDocument extends Document<IScript> {}
|
export interface ScriptDocument extends Document<IScript> {}
|
||||||
|
|
37
services/services/script.service.ts
Normal file
37
services/services/script.service.ts
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import { Context, Service, ServiceBroker, ServiceSchema } from 'moleculer'
|
||||||
|
import DbConnection from '../mixins/db.mixin'
|
||||||
|
import { Script } from '../models/script'
|
||||||
|
|
||||||
|
export default class LiteratureListService extends Service {
|
||||||
|
|
||||||
|
private DbMixin = new DbConnection(Script).start()
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
public constructor (public broker: ServiceBroker, schema: ServiceSchema<{}> = {}) {
|
||||||
|
super(broker)
|
||||||
|
|
||||||
|
this.parseServiceSchema(Service.mergeSchemas({
|
||||||
|
name: 'script',
|
||||||
|
mixins: [this.DbMixin],
|
||||||
|
settings: {
|
||||||
|
fields: [
|
||||||
|
'_id',
|
||||||
|
'body',
|
||||||
|
'video',
|
||||||
|
'title'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
async seedDB(this: Service) {
|
||||||
|
/*await this.adapter.insertMany([
|
||||||
|
{
|
||||||
|
description: 'Essential reading for all coomunists',
|
||||||
|
literature: await this.broker.call('literature-item.find'),
|
||||||
|
name: 'Coomunist Essentials'
|
||||||
|
},
|
||||||
|
])*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, schema))
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue