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.

schema with variable key?

See original GitHub issue

Hi,

Is it possible to define a schema when a key is variable. Example of 2 objects: { 123: { firstname: "firstA", lastname: "lastA" } } { 124: { firstname: "firstB", lastname: "lastB" } }

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
Starefossencommented, Mar 21, 2016

I solved a similar problem by setting strict to false as suggested, and then unsetting and setting the object in question like this:

foo.set(varKey, {});  
foo.set(varKey, varObj);
0reactions
vkarpov15commented, Feb 8, 2019

@znorman-harris this feature’s been in Mongoose for quite a while, see maps

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use mongoose model schema with dynamic keys?
i'm using mongoose with nodejs, and i need to create a dynamic schema model, this is my code ...
Read more >
Variable Key Names for objects
Variable Key Names for objects · jrconlin · Marak Squires · Kris Zyp · Marak Squires · Roland Bouman · Seth Wessitsh ·...
Read more >
Mongoose Query with Dynamic Key that also contains the " ...
So I'm trying to query my MongoDB database using Express & mongoose to fetch documents that have a specific family AND a specific...
Read more >
Mongoose v6.8.2: SchemaTypes
The type Key. type is a special property in Mongoose schemas. When Mongoose finds a nested property named type in your schema, Mongoose...
Read more >
Variables ($vars) | Opis JSON Schema
Variables provide a new way to tackle different scenarios where JSON schema alone fails. This means, that you can use a new keyword...
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