loopbackjs “inq” for array of objects


I have array of object field in loopback model.Want to use "inq" option to filter by day.Already have seen docs but those are for array of strings,not the one Iam finding.

weekDays": [ { "day": "Monday", "startTime": "03:45", "endTime": "04:23" }, { "day": "Wednesday", "startTime": "03:23", "endTime": "12:23" }

Syntax for array of string is like {weekDays:{inq:[]}} ,help what modification has to be done here.


You can use two way in MongoDB

1.Simple find method

db.getCollection('user').find({'weekDays.day' : {$in: ["Monday"]}})

2.By using aggregate

db.getCollection('user').aggregate([ {$unwind:'$weekDays'}, {$match : {'weekDays.day' : {$in : ['Monday']}}}, { "$group": { "_id": "$id", "weekDays" : { "$push": "$weekDays" }, }}, ])

3.aggregate in loopback

var collection = ModelName.getDataSource().connector.collection("myCollection"); collection.aggregate( [ { $unwind:'$weekDays' }, { $match : {'weekDays.day' : {$in : ['Monday']}}}, { "$group": { "_id": "$id", "weekDays" : { "$push": "$weekDays" }}}, ], function(err, data) { if (err) { } else { console.lod(data) }); } } );


  • MongoDB: query Array for 'true' value at index n
  • dplyr + adding replicated vector via 'mutate'
  • Get an Array of Dates of the current week starting on Monday
  • Does this cron expression mean every other Sunday?
  • LINQ to Entities does not recognize the method
  • Javascript hide/show div based on the day of the week?
  • How many people are registering in the day of the week
  • PHP create range of dates
  • Can I have custom UILocalNotification repeat intervals (i.e. weekdays only?)
  • Full calendar business hour constrain on day click event
  • Convert int 60 to a time value of 60 minutes
  • Websocket interval: performance problems on mobile devices?
  • How to acces variable in arrayadapter getView from onItemClick
  • MySQL: select last full 5 minute interval
  • SoX running slow using a ProcessBuilder
  • Drupal: create a node with employee working hours
  • View Azure WebJob Schedule in Portal?
  • Name of day in string format with days to furure
  • LINQ to Entities does not recognize the method 'Int64 Max(Int64, Int64)' method, and this
  • Cannot convert a char value to money. The char value has incorrect syntax
  • PHP Regex Look Around Help
  • Use of qualified name in function parameter
  • What is Closure Compiler?
  • how to pass class attribute and value to markdown syntax
  • Syntax error near unexpected token 'elif'
  • how to read a file in prolog?
  • Getting syntax error in mysql-php. You have an error in your SQL syntax;
  • ZipList with Scalaz
  • Alamofire and Reachability.swift not working on xCode8-beta5
  • Question about instantiating object
  • UWP/C# - Issue with AQS and USB Devices
  • How to make JSON.NET deserialize to Microsoft Date Time?
  • one Local Olampyad Questions on Informatic in 2011
  • Email verification using google app script and google forms
  • Could not find rake using whenever rails
  • Finding past revisions of files in StarTeam w/ .NET SDK / C#
  • Acquiring multiple attributes from .xml file in c#
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • Is there any way to bind data to data.frame by some index?
  • How can i traverse a binary tree from right to left in java?