creating web app Using redis as a primary database redis-om (redis Object Mapping library) - Nextjs App
Basic of CRUD operation in redis database. Use redis as primary database using redis-om
Set your Redis Database
REDIS_URL=___you-redis-cloud-url__
import {Schema , Entity} from "redis-om";
// define class inherite Entity
class Note extends Entity {};
// define schema for Note
const noteSchema = new Schema(
Note, {
title : {type : "string" , textSearch: true},
description : {type : "string" , textSearch: true},
tags : {type : "string"}
},
{
dataStructure : 'JSON'
}
);
export default noteSchema;
export {
noteSchema,
Note
};
POST /api/createnote
Parameter | Type |
---|---|
body |
json |
{
"title" : "title",
"description" : "Description",
"tags" : "General"
}
GET /api/fetch/{id} # fetch specific note
GET /api/fetch/ # fetch all notes
Parameter | Type | Description |
---|---|---|
id |
string |
Not Required. |
PUT /api/update/{id}
Parameter | Type |
---|---|
body |
json |
{
"title" : "updated title",
"description" : "updated Description",
"tags" : "General"
}
GET /api/delete/
Parameter | Type | Description |
---|---|---|
id |
string |
Required. |
GET /api/search?q=__string__
Query | Type | Description |
---|---|---|
q |
string |
Required. |
I'm a Developer i will feel the code then write .
For support, email [email protected]