Vous êtes sur la page 1sur 2

import { BaseRepository } from "../common/base.

repository";
import { Collection, ObjectID } from "mongodb";
export class BorrowerRepository extends BaseRepository {
constructor(collection: string = "borrower_test") {
super(collection);
}
public async postBorrowerInfo (req: any, res: any): Promise<any> {
await this.collection.update({_id: new
ObjectID("5aa1b91e9a570d2124a2b5e4")}, {$set: req});
}
public async getBorrowerInfoByPhoneNumber (phoneNumber: string): Promise<any> {
return await this.collection.aggregate([
{
$project: {
_id : "$_id",
title: "$title",
name: "$name",
surname: "$surname",
phoneNumber: "$phoneNumber",
debtAmount: "$debtAmount",
dob: "$dob",
currentLocationOrder: "$currentLocationOrder",
currentResponse: "$currentResponse",
customerName: "$customerName"
}
},
{ $match: { phoneNumber : phoneNumber} }
]).next();
}
public async getAll(filter: any = {}): Promise<any[]> {
return await this.collection.aggregate([
{
$project: {
_id : "$_id",
title: "$name",
name: "$name",
surname: "$surname",
dob: "$dob",
phoneNumber: "$phoneNumber",
debtAmount: "$debtAmount",
currentLocationOrder: "$currentLocationOrder",
currentResponse: "$currentResponse",
customerName: "$customerName"
}
},
{ $match: { ...filter} }
]).toArray();
}
public async postLocationOrder (req: any, res: any): Promise<any> {
await this.collection.update({_id: new
ObjectID("5aa1b91e9a570d2124a2b5e4")}, {$set: req});
}
public async postResponse (req: any, res: any): Promise<any> {
await this.collection.update({_id: new
ObjectID("5aa1b91e9a570d2124a2b5e4")}, {$set: req});
}
}
Add CommentCollapse

Message Input

Message @Igor Grebenarovic

Vous aimerez peut-être aussi