Mongoose schema won't let me use @ sign in key when inserting to MongoDB with using Node.js. For instance:
var blogSchema = new Schema({
@context : Object //error illegal token
@id : String // illegal token
}, {strict: false});
I tried key with unicode characters like this one:
"\u0040context" = Object // ignored unicode, inserted as context
"\x40context" = Object // ignored unicode, inserted as context
\x40context = Object // illegal token
Also tried with normal way using this link(first way), still cannot define key with @: http://blog.modulus.io/mongodb-tutorial
My purpose is to create document with using JSON-LD format which requires of using @ symbol in key. How to accomplish this? Here are the similar links I have looked for solution:
variable with mongodb dotnotation
Syntax error Unexpected token ILLEGAL Mongo Console
How to use mongoose model schema with dynamic keys?
How to do a query using dot( . ) through Mongoose in Node.js and How to add an empty array
Create a Schema object in Mongoose/Handlebars with custom keys/values
http://mongoosejs.com/docs/schematypes.html