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

how to customize entityId ? #186

Closed makeitworks closed 1 year ago

makeitworks commented 1 year ago

such as i have UserScheme: let UserSchema = new Schema(Entity, { userid: {type:'number'}, name: { type: 'string' } })

the field userid is unique , and i want use userid as entityId , how should i do it ?

Didas-git commented 1 year ago

The short answer is that you cant. What you can do instead is just pass in the user id as the entity id and if you rly rly need it you can add some duplication for ease of use (wouldnt recommend) The way to do it however changes depending on the version you are on (stable or beta)

guyroyse commented 1 year ago

Redis OM 0.4 Beta supports this. Check out the README in the repo for some examples.