22 lines
639 B
TypeScript
22 lines
639 B
TypeScript
import { IShop, OwnerRef } from "./models/Abstraction/IShop";
|
|
import { ShopModel } from "./models/shop.model";
|
|
import { BaseRepository } from "../../common/base/repository";
|
|
|
|
export class ShopRepo extends BaseRepository<IShop> {
|
|
constructor() {
|
|
super(ShopModel);
|
|
}
|
|
|
|
async findWithShopcode(shopCode: number) {
|
|
return this.model.findOne({ shopCode }, { _id: 1, shopName: 1, shopCode: 1, shopDescription: 1, logo: 1 });
|
|
}
|
|
|
|
async findAdminShop() {
|
|
return this.model.findOne({ ownerRef: OwnerRef.ADMIN }).populate({ path: "shipmentMethod" });
|
|
}
|
|
}
|
|
|
|
export function createShopRepo(): ShopRepo {
|
|
return new ShopRepo();
|
|
}
|