Hi everyone I am trying to save an entinty into a redis repository, the driver is correctly connected the schema is created as edxpected same with the repo. The problem comes when I try to save the entity, The exception I am getting is: TypeError: this[#schema].generateId is not a function at Repository.save
.
I already tried with other schema types of old redis-om version usind Class Session extends Entity {}
but I get the same error every time.
the versiĆ³n of redis-node-om
is 0.4.3
.
Here I provide the code that isn’t working:
Middleware.js
const sessionRepository = getSessionRepo(redisClient);
const session = createSessionObj(req);
console.log("[REDIS] **GUARDANDO DATOS EN EL REPOSITORIO DE REDIS**");
const storedSession = await sessionRepository.save(session);
sessionSchema
const sessionSchema = new Schema(
"session",
{
userId: { type: "string", field: "user_id" },
role: { type: "string", field: "user_role" },
jwt: { type: "string", sortable: "yes", field: "user_jwt", weight: 1 },
},
{ dataStructure: "HASH" }
);
getSessionRepo function
function getSessionRepo(redisClient) {
console.log(sessionSchema);
const sessionRepository = new Repository(sessionSchema, redisClient);
console.log(sessionRepository);
return sessionRepository;
}
createSession function:
function createSessionObj(req) {
let session = {};
session.userId = req.body.userId;
session.role = req.body.role;
session.jwt = req.body.tokenJWT;
return session;
}