redis / redis-om-node

Object mapping, and more, for Redis and Node.js. Written in TypeScript.
MIT License
1.18k stars 80 forks source link

EntityId returned with fetch() has type "undefined" #199

Open ktatu opened 1 year ago

ktatu commented 1 year ago

Entities retrieved with fetch() have an entityId with type string | undefined, even though fetching with an entityId that doesn't match anything in the database results in the same entityId being returned.

Code sample:

import { EntityId, Repository, Schema } from "redis-om"
import redisClient from "../services/redisClient"

const schema = new Schema("user", {
    userId: { type: "string" }
})

const repository = new Repository(schema, redisClient)

const fetchUser = async (entityId: string) => {
    const user = await repository.fetch(entityId)

    // userEntityId has type "string | undefined"
    const userEntityId = user[EntityId]
}