Search for MongoDB-independent keyword

I can request values ​​without taking into account the case, but I would like to request the keys discreetly, so users can enter them in all lower case.

This does not work because it is not true. JSON:

{ /^lastName$/i: "Jones" } 

Is there a strategy I could use for this, besides creating a new collection of keys as values?

+6
source share
1 answer

There is currently no way to do this.

MongoDB is “no schema”, but should not be confused with “no schema”. It implies the assumption that your code has some control over the key names that actually appear on the system.

Let me ask you a question around.

  • Is there a good reason users enter case-sensitive keys?
  • Can you just overwrite all the keys in lower case when they are inserted?

Again, MongoDB assumes that you have some information about the available keys. Your question implies that you do not know the keys available. You need to close this gap.

+5
source

Source: https://habr.com/ru/post/893294/


All Articles