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