Can we pass supressReservedKeysWarning to mongoose? #4534
Replies: 3 comments 2 replies
-
Hey @kantorcodes — sure thing! Would you like to open a PR? I will mark this as a Feature Request discussion in the meantime. I think that the property should be added to either the Mongoose adapter itself, or collection configs under the const Pages: CollectionConfig = {
slug: 'pages',
custom: {
supressReservedKeysWarning: true
},
} What do you think? |
Beta Was this translation helpful? Give feedback.
-
Yeah, that would be perfect. Is there any hack to get around this today? |
Beta Was this translation helpful? Give feedback.
-
Same issue, investigating if is there a workaround to silence these warnings. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Link to reproduction
No response
Describe the Bug
Some collections have reserved words in them, and there is no option to supress the warning. When it happens, it appears to not allow certain schemas that do not adhere to Mongoose.
admin-portal-payload-1 | (node:112) [MONGOOSE] Warning:
collection
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 passsupressReservedKeysWarning
as a schema option.admin-portal-payload-1 | (Use
node --trace-warnings ...
to show where the warning was created)admin-portal-payload-1 |
admin-portal-payload-1 | /home/node/app/node_modules/mongoose/lib/helpers/document/compile.js:204
admin-portal-payload-1 | this.$set.call(this.$__[scopeSymbol] || this, path, v);
admin-portal-payload-1 | ^
admin-portal-payload-1 | TypeError: Cannot read properties of undefined (reading 'Symbol(mongoose#Document#scope)')
admin-portal-payload-1 | at Model.set [as collection] (/home/node/app/node_modules/mongoose/lib/helpers/document/compile.js:204:32)
admin-portal-payload-1 | at Function.compile (/home/node/app/node_modules/mongoose/lib/model.js:5237:30)
admin-portal-payload-1 | at Mongoose._model (/home/node/app/node_modules/mongoose/lib/index.js:644:27)
admin-portal-payload-1 | at Mongoose.model (/home/node/app/node_modules/mongoose/lib/index.js:603:27)
admin-portal-payload-1 | at forEach (/home/node/app/node_modules/@payloadcms/db-mongodb/src/init.ts:61:28)
admin-portal-payload-1 | at Array.forEach ()
admin-portal-payload-1 | at Object.init (/home/node/app/node_modules/@payloadcms/db-mongodb/src/init.ts:24:35)
admin-portal-payload-1 | at BasePayload.init (/home/node/app/node_modules/payload/src/payload.ts:356:21)
admin-portal-payload-1 | at processTicksAndRejections (node:internal/process/task_queues:95:5)
admin-portal-payload-1 | at getPayload (/home/node/app/node_modules/payload/src/payload.ts:431:22)
To Reproduce
Create a collection with any reserved name in the slug and run the application.
Payload Version
2.4.0
Adapters and Plugins
db-mongodb
Beta Was this translation helpful? Give feedback.
All reactions