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

typo fix #12925

Merged
merged 2 commits into from
Jan 18, 2023
Merged

typo fix #12925

Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@
* fix(index.d.ts): ValidationError `errors` only contains CastError or ValidationError #11369 [Uzlopak](https://github.com/Uzlopak)
* fix(index.d.ts): make InsertManyResult.insertedIds return an array of Types.ObjectId by default #11197
* fix(index.d.ts): allow pre('save') middleware with pre options #11257
* fix(index.d.ts): add `supressReservedKeysWarning` option to schema #11439 [hiukky](https://github.com/hiukky)
* fix(index.d.ts): add `suppressReservedKeysWarning` option to schema #11439 [hiukky](https://github.com/hiukky)
* docs(connections): improve replica set hostname docs with correct error message and info about `err.reason.servers` #11200
* docs(populate): add virtual populate match option documentation #11411 [remirobichet](https://github.com/remirobichet)
* docs(document): add note to API docs that flattenMaps defaults to `true` for `toJSON()` but not `toObject()` #11213
Expand Down
2 changes: 1 addition & 1 deletion docs/migrating_to_6.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ const schema = new Schema({

<h3 id="schema-reserved-names-warning"><a href="#schema-reserved-names-warning">Schema Reserved Names Warning</a></h3>

Using `save`, `isNew`, and other Mongoose reserved names as schema path names now triggers a warning, not an error. You can suppress the warning by setting the `supressReservedKeysWarning` in your schema options: `new Schema({ save: String }, { supressReservedKeysWarning: true })`. Keep in mind that this may break plugins that rely on these reserved names.
Using `save`, `isNew`, and other Mongoose reserved names as schema path names now triggers a warning, not an error. You can suppress the warning by setting the `suppressReservedKeysWarning` in your schema options: `new Schema({ save: String }, { suppressReservedKeysWarning: true })`. Keep in mind that this may break plugins that rely on these reserved names.

<h3 id="subdocument-paths"><a href="#subdocument-paths">Subdocument Paths</a></h3>

Expand Down
4 changes: 2 additions & 2 deletions lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -924,10 +924,10 @@ Schema.prototype.path = function(path, obj) {

// some path names conflict with document methods
const firstPieceOfPath = path.split('.')[0];
if (reserved[firstPieceOfPath] && !this.options.supressReservedKeysWarning) {
if (reserved[firstPieceOfPath] && !this.options.suppressReservedKeysWarning) {
const errorMessage = `\`${firstPieceOfPath}\` is a reserved schema pathname and may break some functionality. ` +
'You are allowed to use it, but use at your own risk. ' +
'To disable this warning pass `supressReservedKeysWarning` as a schema option.';
'To disable this warning pass `suppressReservedKeysWarning` as a schema option.';

utils.warn(errorMessage);
}
Expand Down
4 changes: 2 additions & 2 deletions test/document.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7510,7 +7510,7 @@ describe('document', function() {
});

it('handles nested properties named `on` (gh-11656)', async function() {
const schema = new mongoose.Schema({ on: String }, { supressReservedKeysWarning: true });
const schema = new mongoose.Schema({ on: String }, { suppressReservedKeysWarning: true });
const Model = db.model('Test', schema);

await Model.create({ on: 'test string' });
Expand Down Expand Up @@ -12043,7 +12043,7 @@ describe('document', function() {
schema: { type: 'String', required: true },
title: { type: 'String', required: true },
authors: [AuthorSchema]
}, { supressReservedKeysWarning: true });
}, { suppressReservedKeysWarning: true });

const Book = db.model('Book', BookSchema);

Expand Down
2 changes: 1 addition & 1 deletion test/model.populate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,7 @@ describe('model: populate:', function() {
assert.strictEqual(returned.fans[3], null);
});

it('supports `retainNullValues` while supressing _id of subdocument', async function() {
it('supports `retainNullValues` while suppressing _id of subdocument', async function() {
const BlogPost = db.model('BlogPost', blogPostSchema);
const User = db.model('User', userSchema);

Expand Down
4 changes: 2 additions & 2 deletions test/schema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1440,15 +1440,15 @@ describe('schema', function() {
assert.ok(lastWarnMessage.includes(`\`${reservedProperty}\` is a reserved schema pathname`), lastWarnMessage);
});

it(`\`${reservedProperty}\` when used as a schema path doesn't log a warning if \`supressReservedKeysWarning\` is true`, async() => {
it(`\`${reservedProperty}\` when used as a schema path doesn't log a warning if \`suppressReservedKeysWarning\` is true`, async() => {
// Arrange
const emitWarningStub = sinon.stub(process, 'emitWarning').returns();


// Act
new Schema(
{ [reservedProperty]: String },
{ supressReservedKeysWarning: true }
{ suppressReservedKeysWarning: true }
);

const lastWarnMessage = emitWarningStub.args[0] && emitWarningStub.args[0][0];
Expand Down
2 changes: 1 addition & 1 deletion test/types/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function gh11439() {
const bookSchema = new Schema<Book>({
collection: String
}, {
supressReservedKeysWarning: true
suppressReservedKeysWarning: true
});
}

Expand Down
4 changes: 2 additions & 2 deletions types/schemaoptions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ declare module 'mongoose' {

/**
* Using `save`, `isNew`, and other Mongoose reserved names as schema path names now triggers a warning, not an error.
* You can suppress the warning by setting { supressReservedKeysWarning: true } schema options. Keep in mind that this
* You can suppress the warning by setting { suppressReservedKeysWarning: true } schema options. Keep in mind that this
* can break plugins that rely on these reserved names.
*/
supressReservedKeysWarning?: boolean,
suprpessReservedKeysWarning?: boolean,
IslandRhythms marked this conversation as resolved.
Show resolved Hide resolved

/**
* Model Statics methods.
Expand Down