-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathListingBuyModel.ts
30 lines (27 loc) · 969 Bytes
/
ListingBuyModel.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { Entity, Schema } from "redis-om";
import { PriceCurrency } from "../generated_graphql_types";
import { dbClientWithoutConnect } from ".";
export interface ListingBuyModel {
buyer_id: string;
listing_id: string;
price: number;
bought_at: string;
currency: PriceCurrency;
owner_id: string;
}
export class ListingBuyModel extends Entity {}
export const listingBuyModelSchema = new Schema(
ListingBuyModel,
{
buyer_id: { type: "string", indexed: true },
listing_id: { type: "string", indexed: true },
bought_at: { type: "string", indexed: true },
price: { type: "number", indexed: true }, // since the user can increase the price, we need to store the original price
currency: { type: "string", indexed: true },
owner_id: { type: "string", indexed: true }, // this de-normalization will help while trying to fetch all products which got sold of a user
},
{
dataStructure: "JSON",
indexedDefault: true,
}
);