不要怂,就是干,撸起袖子干!

Commit 3e9441bc by Sahil Rajput Committed by GitHub

docs(model-querying-basics): clarify example (#12999)

1 parent ac39f8ac
...@@ -18,7 +18,7 @@ console.log("Jane's auto-generated ID:", jane.id); ...@@ -18,7 +18,7 @@ console.log("Jane's auto-generated ID:", jane.id);
The [`Model.create()`](../class/lib/model.js~Model.html#static-method-create) method is a shorthand for building an unsaved instance with [`Model.build()`](../class/lib/model.js~Model.html#static-method-build) and saving the instance with [`instance.save()`](../class/lib/model.js~Model.html#instance-method-save). The [`Model.create()`](../class/lib/model.js~Model.html#static-method-create) method is a shorthand for building an unsaved instance with [`Model.build()`](../class/lib/model.js~Model.html#static-method-build) and saving the instance with [`instance.save()`](../class/lib/model.js~Model.html#instance-method-save).
It is also possible to define which attributes can be set in the `create` method. This can be especially useful if you create database entries based on a form which can be filled by a user. Using that would, for example, allow you to restrict the `User` model to set only an username and an address but not an admin flag: It is also possible to define which attributes can be set in the `create` method. This can be especially useful if you create database entries based on a form which can be filled by a user. Using that would, for example, allow you to restrict the `User` model to set only an username but not an admin flag (i.e., `isAdmin`):
```js ```js
const user = await User.create({ const user = await User.create({
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!