chore: added comments to the data models
This commit is contained in:
parent
449f813ba2
commit
750a7f21d1
src
@ -1,10 +1,10 @@
|
|||||||
export class NostrEvent {
|
export class NostrEvent {
|
||||||
constructor(
|
constructor(
|
||||||
public id: string,
|
public nostrId: string, // nostr unique identifier
|
||||||
public pubkey: string,
|
public pubkey: string, // public key of the event creator
|
||||||
public created_at: number,
|
public created_at: number, // timestamp
|
||||||
public kind: number,
|
public kind: number, // event type, e.g., review, article, comment
|
||||||
public tags: [string][],
|
public tags: [string][], // array of keywords or hashtags
|
||||||
public content: string
|
public content: string // text content of the event
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,11 @@ import { ObjectId } from 'mongodb'
|
|||||||
|
|
||||||
export class Review {
|
export class Review {
|
||||||
constructor(
|
constructor(
|
||||||
public eventId: string,
|
public eventId: string, // foreign key referencing the nostrEvents collection
|
||||||
public productId: string,
|
public productId: string, // unique identifier for the product
|
||||||
public rating: number,
|
public rating: number, // numerical rating, e.g., 1-100
|
||||||
public reviewText: string,
|
public reviewText: string, // text content of the review
|
||||||
public testingNotes: string[],
|
public tastingNotes: string[], // array of tasting notes, e.g., flavours, aromas
|
||||||
public id?: ObjectId
|
public id?: ObjectId // database object id
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,12 @@ import { collections } from '../services/database.service'
|
|||||||
import { Review } from '../models'
|
import { Review } from '../models'
|
||||||
|
|
||||||
// Global Config
|
// Global Config
|
||||||
export const reviewRouter = express.Router()
|
export const reviewsRouter = express.Router()
|
||||||
|
|
||||||
reviewRouter.use(express.json())
|
reviewsRouter.use(express.json())
|
||||||
|
|
||||||
// GET
|
// GET
|
||||||
reviewRouter.get('/', async (_req: Request, res: Response) => {
|
reviewsRouter.get('/', async (_req: Request, res: Response) => {
|
||||||
try {
|
try {
|
||||||
const reviews = await collections.reviews?.find({}).toArray()
|
const reviews = await collections.reviews?.find({}).toArray()
|
||||||
|
|
||||||
@ -23,9 +23,10 @@ reviewRouter.get('/', async (_req: Request, res: Response) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// POST
|
// POST
|
||||||
reviewRouter.post('/', async (req: Request, res: Response) => {
|
reviewsRouter.post('/', async (req: Request, res: Response) => {
|
||||||
try {
|
try {
|
||||||
const review = req.body as Review
|
const review = req.body as Review
|
||||||
|
|
||||||
const result = await collections.reviews?.insertOne(review)
|
const result = await collections.reviews?.insertOne(review)
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user