-
Can I enforce a property on a class when creating a new record? As far as I can see, there is no way to create a schema for the data. Are you planning to include such behaviour? class User {
constructor(name) {
this.name = name;
}
}
nucleoid.register(User);
// I need to manually check the fields for every parameter.
app.post("/users", (req) => new User(req.body.name)); With this, there is also no way to make a field unique. Am I understanding it correctly? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I am glad that you opened this up in discussions because we are still designing the runtime, in current stage, we are working to integrate with OpenAPI here. By the design, when it gets the JavaScript part, data will be already validated according the defined API, and for all of business logic and constraint logic, it is just the pure JavaScript, like for your example, unique constraint, it is going to be look like this: app.post("/users", (req) => {
const username = req.body.username
if(User[username]) {
throw "USER_ALREADY_REGISTERED"
}
return new User(req.body.username)
}); The way that Nucleoid works is like the runtime rerenders JavaScript is passed by, manages control flow as well as |
Beta Was this translation helpful? Give feedback.
I am glad that you opened this up in discussions because we are still designing the runtime, in current stage, we are working to integrate with OpenAPI here. By the design, when it gets the JavaScript part, data will be already validated according the defined API, and for all of business logic and constraint logic, it is just the pure JavaScript, like for your example, unique constraint, it is going to be look like this:
The way that Nucleoid works is like the runtime rerenders JavaScript is passed by, manages cont…