How to have a variable as key when using mongoose [duplicate]
This question already has an answer here:
Associative array with mongoose schema?
2 answers
Mongoose variable key name
4 answers
How to use mongoose model schema with dynamic keys?
1 answer
I am fetching a document that has an id that I am in position of.
For example the db has this kind of schema:
"id1": {
...
}
"id2": {
...
}
I am running a for over the json and data[i].address is id + i,
I want to update every key and value that are inside these id's but I can't use a variable as a key for mongoose, it throws an error.
Any trick to doing that?
javascript node.js database mongodb mongoose
marked as duplicate by Neil Lunn
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 '18 at 2:13
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Associative array with mongoose schema?
2 answers
Mongoose variable key name
4 answers
How to use mongoose model schema with dynamic keys?
1 answer
I am fetching a document that has an id that I am in position of.
For example the db has this kind of schema:
"id1": {
...
}
"id2": {
...
}
I am running a for over the json and data[i].address is id + i,
I want to update every key and value that are inside these id's but I can't use a variable as a key for mongoose, it throws an error.
Any trick to doing that?
javascript node.js database mongodb mongoose
marked as duplicate by Neil Lunn
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 '18 at 2:13
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
If you mean "within another property" then that's typicallyMixed
but you should seriously consider a regular array of objects with fixed key names. If you mean at the document root, then that's the{ strict: false }
option as noted.
– Neil Lunn
Nov 20 '18 at 2:14
add a comment |
This question already has an answer here:
Associative array with mongoose schema?
2 answers
Mongoose variable key name
4 answers
How to use mongoose model schema with dynamic keys?
1 answer
I am fetching a document that has an id that I am in position of.
For example the db has this kind of schema:
"id1": {
...
}
"id2": {
...
}
I am running a for over the json and data[i].address is id + i,
I want to update every key and value that are inside these id's but I can't use a variable as a key for mongoose, it throws an error.
Any trick to doing that?
javascript node.js database mongodb mongoose
This question already has an answer here:
Associative array with mongoose schema?
2 answers
Mongoose variable key name
4 answers
How to use mongoose model schema with dynamic keys?
1 answer
I am fetching a document that has an id that I am in position of.
For example the db has this kind of schema:
"id1": {
...
}
"id2": {
...
}
I am running a for over the json and data[i].address is id + i,
I want to update every key and value that are inside these id's but I can't use a variable as a key for mongoose, it throws an error.
Any trick to doing that?
This question already has an answer here:
Associative array with mongoose schema?
2 answers
Mongoose variable key name
4 answers
How to use mongoose model schema with dynamic keys?
1 answer
javascript node.js database mongodb mongoose
javascript node.js database mongodb mongoose
asked Nov 20 '18 at 2:08
RandomizerRandomizer
9510
9510
marked as duplicate by Neil Lunn
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 '18 at 2:13
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Neil Lunn
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 '18 at 2:13
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
If you mean "within another property" then that's typicallyMixed
but you should seriously consider a regular array of objects with fixed key names. If you mean at the document root, then that's the{ strict: false }
option as noted.
– Neil Lunn
Nov 20 '18 at 2:14
add a comment |
If you mean "within another property" then that's typicallyMixed
but you should seriously consider a regular array of objects with fixed key names. If you mean at the document root, then that's the{ strict: false }
option as noted.
– Neil Lunn
Nov 20 '18 at 2:14
If you mean "within another property" then that's typically
Mixed
but you should seriously consider a regular array of objects with fixed key names. If you mean at the document root, then that's the { strict: false }
option as noted.– Neil Lunn
Nov 20 '18 at 2:14
If you mean "within another property" then that's typically
Mixed
but you should seriously consider a regular array of objects with fixed key names. If you mean at the document root, then that's the { strict: false }
option as noted.– Neil Lunn
Nov 20 '18 at 2:14
add a comment |
0
active
oldest
votes
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you mean "within another property" then that's typically
Mixed
but you should seriously consider a regular array of objects with fixed key names. If you mean at the document root, then that's the{ strict: false }
option as noted.– Neil Lunn
Nov 20 '18 at 2:14