redis-om-node
redis-om-node copied to clipboard
Add default value to Schema
It'd be nice to provide a default value to a Schema so that when an Entity is created, you don't have to set a field if you don't want to. Requested by @nraychaudhuri.
Something like this?
class Album extends Entity { };
const schema = new Schema(Album)
schema.definition // { redis: { type: "string" } }
Thinking this:
const schema = new Schema(Album, {
artist: { type: 'string', default: 'Mushroomhead' },
year: { type: 'number', default: 2020 }
}
and
Thinking this:
const schema = new Schema(Album, { artist: { type: 'string', default: 'Mushroomhead' }, year: { type: 'number', default: 2020 } }
one more thing
how to add another schema in type array
{ "totalPlayer": 5, "players":[ { "key":"value" } ] }
This has been asked for in several other issues and I am actively working on it.
@guyroyse Any news?
Code for nested objects in JSON is done and in a review process. Should be released next week when I get back from a conference.