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

fix existing faq for array-defaults #6695

Merged
merged 2 commits into from Jul 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion docs/faq.jade
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ block content
**Q**. How can I change mongoose's default behavior of initializing an array
path to an empty array so that I can require real data on document creation?

**A**. You can set the default of the array to a function that returns null.
**A**. You can set the default of the array to a function that returns `undefined`.
```javascript
const CollectionSchema = new Schema({
field1: {
Expand All @@ -307,6 +307,18 @@ block content
});
```

**Q**. How can I initialize an array path to `null`?

**A**. You can set the default of the array to a function that returns `null`.
```javascript
const CollectionSchema = new Schema({
field1: {
type: [String],
default: () => { return null; }
}
});
```

<hr id="aggregate-casting" />

**Q**. Why does my aggregate $match fail to return the document that my find query
Expand Down