50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import { ObjectType } from 'type-graphql';
|
|
|
|
import { Permission } from '@seed/interfaces/permission';
|
|
|
|
import { AccountTypeEnum } from '@src/accounts/account.components';
|
|
import { StreamDBInterfaceSchema, StreamDBSchema, StreamSchema } from './schemas/stream.schema';
|
|
import { EngineModel } from '@seed/engine/EngineModel';
|
|
import { IEngineSchema } from '@seed/engine/EngineSchema';
|
|
import { ModelCollectionEnum } from '@src/__indexes/__collections';
|
|
import { plainToClass } from 'class-transformer';
|
|
import { CustomSearchEngine } from '@seed/services/database/DBRequestService';
|
|
import { StreamArgs } from './schemas/stream.schema.input';
|
|
|
|
const permissions: Permission = {
|
|
c: [AccountTypeEnum.admin],
|
|
r: [AccountTypeEnum.admin],
|
|
w: [AccountTypeEnum.admin],
|
|
d: [AccountTypeEnum.admin],
|
|
};
|
|
|
|
@ObjectType()
|
|
export default class StreamEngineModel extends EngineModel<StreamDBInterfaceSchema, StreamDBSchema, StreamSchema> {
|
|
public constructor(input?: StreamDBInterfaceSchema & Partial<IEngineSchema>) {
|
|
const dataInit = plainToClass(StreamDBSchema, input || {});
|
|
super({
|
|
// ...init,
|
|
collectionName: ModelCollectionEnum.streams,
|
|
permissions: permissions,
|
|
dataInit,
|
|
});
|
|
}
|
|
|
|
plainToClass(plain: any): StreamSchema | StreamSchema[] {
|
|
return plainToClass(StreamSchema, plain);
|
|
}
|
|
|
|
searchEngine(): CustomSearchEngine<StreamArgs> {
|
|
const sEngine: CustomSearchEngine<StreamArgs> = {
|
|
documentKey: {
|
|
operation: '$eq',
|
|
},
|
|
hookStatus: {
|
|
operation: '$eq',
|
|
},
|
|
};
|
|
|
|
return sEngine;
|
|
}
|
|
}
|