Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default value to Schema #69

Open
guyroyse opened this issue Apr 19, 2022 · 6 comments
Open

Add default value to Schema #69

guyroyse opened this issue Apr 19, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@guyroyse
Copy link
Contributor

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.

@Didas-git
Copy link
Contributor

Something like this?

class Album extends Entity { };

const schema = new Schema(Album)

schema.definition // { redis: { type: "string" } }

@guyroyse
Copy link
Contributor Author

Thinking this:

const schema = new Schema(Album, {
  artist: { type: 'string', default: 'Mushroomhead' },
  year: { type: 'number', default: 2020 }
}

@hiteshpatelic
Copy link

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"
}
]
}

@guyroyse
Copy link
Contributor Author

This has been asked for in several other issues and I am actively working on it.

@guyroyse guyroyse added the enhancement New feature or request label Aug 29, 2022
@eladcandroid
Copy link

@guyroyse Any news?

@guyroyse
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants