question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using reserved keyword as schema key

See original GitHub issue

In our project we have existing database scheme and there is no longer possible to change it. Is where workaround to use reserved key in schema? We need to use options key.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
vkarpov15commented, Aug 27, 2016

This issue was specifically about using options as a schema key, which is ok right now. As for using reserved keywords, we don’t plan on allowing using things like save as schema keys right now, because that would require massive api changes

2reactions
Jokerocommented, Aug 9, 2015

I agree with @smonkey72. I think mongoose should use prefixed names of reserved keys like this:

var blogSchema = new Schema({
  title:  String,
  author: String,
  body:   String,
  date: { // here
      $type:    Date, 
      $default: Date.now 
  },
  meta: {
    votes: Number,
    favs:  Number
  }
});

Or use properties for object fields (like JSON Schema):

var blogSchema = new Schema({
  title:  String,
  author: String,
  body:   String,
  date: { 
      type:    Date,
      default: Date.now 
  },
  meta: { // here
    properties: {
        votes: Number,
        favs:  Number
    }
  }
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Reserved schema names and reserved words - IBM
Reserved schema names and reserved words. There are restrictions on the use of certain names that are required by the database manager.
Read more >
Reserved words and schemas | Databricks on AWS
Reserved words are literals used as keywords by the SQL language which should not be used as identifiers to avoid unexpected behavior. Reserved...
Read more >
How to escape SQL reserved keywords with JPA and Hibernate
Learn how to escape SQL reserved keywords when using JPA and Hibernate. Reserved keywords can be escaped in table or column names.
Read more >
Reserved keywords - Amazon Athena - AWS Documentation
Athena uses the following list of reserved keywords in SQL SELECT statements and in queries on views. If you use these keywords as...
Read more >
9.3 Keywords and Reserved Words - MySQL :: Developer Zone
Keywords are words that have significance in SQL. Certain keywords, such as SELECT , DELETE , or BIGINT , are reserved and require...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found