Created
July 4, 2022 06:58
Event manager repository code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Entity, Schema } from 'redis-om'; | |
import { redisClient } from '../db/index.js'; | |
class EventRepository extends Entity {} | |
const eventSchema = new Schema(EventRepository, { | |
title: { type: 'text' }, | |
description: { type: 'text' }, | |
category: { type: 'string' }, | |
venue: { type: 'string' }, | |
locationPoint: { type: 'point' }, | |
startDate: { type: 'date', sortable: true }, | |
endDate: { type: 'date', sortable: true }, | |
imageUrl: { type: 'string' }, | |
userId: { type: 'string' }, | |
createdAt: { type: 'date', sortable: true }, | |
updatedAt: { type: 'date', sortable: true }, | |
}, { | |
dataStructure: 'HASH' | |
}); | |
const eventRepository = redisClient.fetchRepository(eventSchema); | |
await eventRepository.createIndex(); | |
export { eventRepository }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment