Query modifier contains an unexpected token ":"

For my API project, I have opted to use sailsjs as my framework. The documentation at provides a list of query modifiers that can be used.

User.find({
  or: [
    name: { startsWith: 'thelas' },
    email: { startsWith: 'thelas' }
  ]
}, cb);

Using this information, I created the following modifier:

var query = {
    or: [
        cityName: {
            contains: req.param('city')
        },
        zoneNumber: {
            startsWith: req.param('query')
        }
    ]
};

I then passed the query like this:

User.find(query, function(err, res){});

However, I encountered an error related to the format of the query:

cityName: {
        ^
SyntaxError: Unexpected token :

Could this error be due to breaking JSON format rules, or is it a less common issue originating from the framework itself?

Answer №1

Give this a shot:

let searchQuery = {
    or: [{
        cityName: {
            includes: req.param('city')
        },
        zoneNumber: {
            startsWith: req.param('query')
        }
    }]
};

Don't forget to include {}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tick the checkboxes if they are found in the JSON data

After parsing this JSON object: [{"id_distrib":"1"},{"id_distrib":"44"},{"id_distrib":"4"}] I need to select the following checkboxes: <input id="1" class="cb_distrib_linux" type="checkbox"value="1">Achlinux <input id="2" class="cb_distrib_lin ...

The mistake is indicating the npm title of a package that is not present

https://i.sstatic.net/5bywN.png An issue has arisen - the module cannot be found, even though such a module does not actually exist. The correct module name should be babel-plugin-proposal-class-properties (and the error is showing as 'babel-plugin-t ...

I have developed a node app that is currently functioning on my local machine. However, I am seeking assistance to make the necessary modifications to server.js in order for

I have successfully created a node app that is up and running locally. However, I am in need of assistance in modifying the server.js file so that it can function properly on heroku. Here is the current server.js code: var http = require('http' ...

Bundling and minifying Angular2 assets

In the world of ASP.NET (or gulp), bundling and minification are taken care of. However, a different issue arises when following Angular2 tutorials: the view HTML is typically embedded within the component itself. Fortunately, there is a way to separate th ...

Is it permissible to have circular references between JSON Schemas that are stored in separate files?

I am currently working with two JSON schemas that reference each other: schema.task.json and schema.dependency.json: //file: schema.task.json { "$schema": "http://json-schema.org/draft-04/schema", "type": "object", "properties": { "Dep ...

The Vuex state keeps acting mysterious by claiming to be undefined

Here is my post.js located in src > store > post.js: import Vuex from 'vuex' import Vue from 'vue' import axios from 'axios' Vue.use(Vuex) export default new Vuex.Store({ state: { testState: 'Hello&apo ...

React - CSS Transition resembling a flip of a book page

As I delve into more advanced topics in my journey of learning React and Front Web Dev, I discovered the ReactCSSTransitionGroup but learned that it is no longer maintained so we now use CSSTransitionGroup. I decided to create a small side project to expe ...

Error in Formatting Labels in CSS

I currently have a form with textboxes that include validation. Everything works smoothly when clicking the save button for the first time, but if we fill out the textboxes and then remove the text, an error message is displayed on the textboxes. You can v ...

Tips for refreshing a D3.js bubble chart with live JSON data updates

Currently delving into d3 and experimenting with transforming a static bubble chart into a dynamic one that adjusts by removing or adding bubbles based on JSON changes. I am aiming to have the JSON file refreshed every 5 seconds to update the bubble chart ...

Unable to locate a type definition file for module 'vue-xxx'

I keep encountering an error whenever I attempt to add a 3rd party Vue.js library to my project: Could not find a declaration file for module 'vue-xxx' Libraries like 'vue-treeselect', 'vue-select', and 'vue-multiselect ...

Style the labels on the axis of Frappe Charts with colors (potentially utilizing the appropriate CSS selector)

Is it possible to style the x and y axis labels in a Frappe chart with different colors? https://i.stack.imgur.com/A3vUq.png While trying to identify the CSS selectors using Chrome DevTools, I found that a single text element (representing an x axis labe ...

A guide on storing multiple values in a JSON format using Java

Currently, I am working on fetching a list of values from the JDBC database with multiple columns. To tackle this issue, I decided to create a JSON object structured like the example below: { "Results 1": { "IP": "192.1 ...

I am experiencing issues with the detection of mouseover events on an SVG circle

I am currently working on a d3 map with zoom functionality that displays circles representing different cities. However, I am facing an issue where the mouseover event for the circles (which shows tooltips and clicking reveals some lines) seems to only reg ...

Pull the data from jQuery/JavaScript/AJAX and store it in the database using ASP.NET/C#

I am working on creating a form that includes textboxes and a five star rating feature. The goal is to save the data entered in the fields into a database upon submitting. While implementing the textboxes was straightforward, I am facing challenges with e ...

retrieve JSON object from deferred response of AJAX request

After utilizing Ajax to send an item to a SharePoint list, I aim to incorporate the jsonObject received in response into a list of items. Located in AppController.js $scope.addListItem = function(listItem){ $.when(SharePointJSOMService.addListIte ...

What is the best way to incorporate a sidebar menu in an HTML webpage?

I am interested in creating a sidebar menu for my website using either HTML, CSS, or JavaScript. The W3 Schools website has a side menu that I find appealing and would like to create something similar. ...

Leveraging CSS or JavaScript for Displaying or Concealing Vacant Content Sections

I'm working on developing a page template that utilizes section headers and dynamically pulled content from a separate database. The current setup of the page resembles the following structure: <tr> <td> <h3> ...

Unable to retrieve JSON data from converting TXT using JavaScript, resulting in undefined output

After converting txt to JSON, I encountered an issue. const txt = JSON.stringify(`{ ErrorList: [{ 80: 'Prepared' }], Reference: [ { 'Rule Name': 'Missing 3', 'Rule ID': 1, 'Rule Des& ...

Tips on Handling Multiple Versions of jQuery

I'm seeking your guidance on a particular issue at hand. I am part of the development team for a large web application that heavily relies on jQuery and has been in constant development for the past 7-8 years. Over this time, several versions of jQue ...

What is the best way to use Shadcn to incorporate a calendar that takes up half of my website?

Currently, I am in the process of developing a scheduling appointment system. My main challenge is getting the calendar to take up half of my page's space. Despite my attempts to adjust its height and width, I have not been successful in seeing any ch ...