Allow `schema` as a schema path name
See original GitHub issueDo you want to request a feature or report a bug? Bug
What is the current behavior?
When i set schema name schema
,
mongoose throw err
mongoose/lib/schema.js
line 528
If the current behavior is a bug, please provide the steps to reproduce.
const schema = new Schema({ 'schema': { type: String, default: '{}'}, });
What is the expected behavior?
I can set name schema
in Schema
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that “latest” is not a version.
Mongoose version 5.4.7
5.9.9 alse have this problem
https://github.com/Automattic/mongoose/blob/master/lib/schema.js#L645
Nodejs version 12
Issue Analytics
- State:
- Created 3 years ago
- Comments:14
Top Results From Across the Web
Documentation: 15: 5.9. Schemas - PostgreSQL
To allow many users to use one database without interfering with each other. ... The first schema named in the search path is...
Read more >Mongoose v6.8.2: Schemas
In these cases, Mongoose only creates actual schema paths for leaves in the tree. ... define a schema const animalSchema = new Schema({...
Read more >Introduction to Mongoose Schemas - Mastering JS
This object defines what paths a schema has. For example, the below userSchema has a name path and an age path.
Read more >node.js - `options` may not be used as a schema pathname
Mongoose has a number of Reserved schema names that can't be used, to avoid conflicting with Mongoose's internal implementation.
Read more >Structuring a complex schema — Understanding JSON ...
Complex parts of the schema can be defined in $defs with descriptive names and referenced where it's needed. This allows readers of the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In that case I would rename the schema field into a different field name. I’ve always found thesaurus quite helpful in finding synonyms.
Some path names unfortunately do conflict with existing methods and properties. However, there are ways for us to work around this. I’ll keep this open for a future release.