I am creating a Meteor training project. It has a collection, in its documents there is a property called keywords, which is an array of strings. I have a second array of strings. I want to filter the collection so that it returns only those documents that the keywords intersect with this second array, i.e. Both arrays have one or more identical elements. Is it possible?
Yes, the query will look like this:
var searchKeywords = ['a','b','c','d'] MyCollection = new Mongo.Collection('mycollection'); MyCollection.insert({ keywords: ['x','y','a','b'] }); // returns some ID MyCollection.findOne({ keywords: { $in: searchKeywords } })._id // returns the same ID
Source: https://habr.com/ru/post/1237995/More articles:Rails: why does my server redirect http to https - ruby-on-railsGOCR does not use learning outcomes - machine-learningSort faster in a racket using a hash table - sortingusing pandas in python to add CSV files to one - pythonUsing a while loop in Pycharm and Kivy - pythonMongoDB Java API: Full-Text Search - javaRemove parentheses around integers in a string - pythonThe plot of 4D data in the form of a layered heat map with a grid in R - rPython - How to make a daemon from a GUI application on Mac OS X? - pythonHow to hide app icon from Mac OS X dock - carbonAll Articles