sql >> Base de Datos >  >> NoSQL >> MongoDB

¿Cómo verificar si un campo de matriz contiene un valor único u otra matriz en MongoDB?

Prueba esto:

db.blogpost.find({ 'tags' : 'tag1'}); //1
db.blogpost.find({ 'tags' : { $all : [ 'tag1', 'tag2' ] }}); //2
db.blogpost.find({ 'tags' : { $in : [ 'tag3', 'tag4' ] }}); //3