-
Notifications
You must be signed in to change notification settings - Fork 2
/
ListingModel.ts
80 lines (68 loc) · 2.3 KB
/
ListingModel.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { Entity, Schema } from "redis-om";
import { ListingType, PriceCurrency } from "../generated_graphql_types";
import { dbClientWithoutConnect } from ".";
export interface ListingModel {
// id: ID!
// currency: PriceCurrency!
// desc_full_markdown: String!
// includes_chat_support: Boolean!
// includes_video_call_support: Boolean!
// listing_type: ListingType!
// name: String!
// price: Float!
// show_in_discover: Boolean!
// video_duration: Int! # it will be 0 if [includes_video_call_support] is false
// cover_image_url: String!
// reviews_score: Float!
// number_of_reviews: Int!
// author: UserPublicInfo!
// tags: [String!]!
currency: PriceCurrency;
desc_full_markdown: string;
listing_type: ListingType;
name: string;
price: number;
show_in_discover: boolean;
cover_image_url: string;
reviews_score: number;
number_of_reviews: number;
tags: string[];
author_id: string;
published_at: string;
is_published: boolean;
// The following value is only valid for product listings
number_of_product_items: number;
// The following three are only valid for service listings
includes_chat_support: boolean;
includes_video_call_support: boolean;
video_duration: number;
created_at: string;
}
export class ListingModel extends Entity {}
export const listingModelSchema = new Schema(
ListingModel,
{
currency: { type: "string", indexed: true },
desc_full_markdown: { type: "string" },
includes_chat_support: { type: "boolean", indexed: true },
includes_video_call_support: { type: "boolean", indexed: true },
listing_type: { type: "string", indexed: true },
name: { type: "text", indexed: true },
price: { type: "number" },
show_in_discover: { type: "boolean", indexed: true },
video_duration: { type: "number" },
cover_image_url: { type: "string" },
reviews_score: { type: "number" },
number_of_reviews: { type: "number", sortable: true },
tags: { type: "string[]", indexed: true },
author_id: { type: "string", indexed: true },
published_at: { type: "date", sortable: true },
is_published: { type: "boolean", indexed: true },
created_at: { type: "date" }, // it's just for analytics
number_of_product_items: { type: "number" },
},
{
dataStructure: "JSON",
indexedDefault: true,
}
);