Files
ZYZ/shared/db/DicShopList.ts

37 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
import { ShopItem } from '../domain/dbGeneral';
/**
* 分红记录表
**/
@modelOptions({ schemaOptions: { id: false } })
@index({ shopId: 1 })
export default class DicShopList extends BaseModel {
@prop({ required: true })
shopId: number; // 商店id dic_zyz_shopList内的id
@prop({ required: true, default: false })
useJson: boolean; // 如果为true则会随dic_zyz_shop表内商品增加而增加items只提供顺序折扣等为false则只提供items里的商品
@prop({ required: true, default: [], _id: false, type: () => ShopItem })
items: ShopItem[]; // 商店id dic_zyz_shopList内的id
// public static async findByShopId(shopId: number) {
// const rec: DicShopListType = await DicShopListModel.findOne({ shopId }).lean();
// return rec;
// }
// public static async createShop(shopId: number, useJson: boolean, item: ShopItem) {
// const rec: DicShopListType = await DicShopListModel.findOneAndUpdate({ shopId }, { useJson, $push: { items: item } }, { new: true, upsert: true }).lean();
// return rec;
// }
}
export const DicShopListModel = getModelForClass(DicShopList);
export interface DicShopListType extends Pick<DocumentType<DicShopList>, keyof DicShopList>{}
export type DicShopListParam = Partial<DicShopListType>;