Query on pointer in parse.com Objects in Javascript

parse query javascript
parse object extend
parse server update object
parse fetch
parse server api
parse user documentation
parse server nodejs
parse server error codes

I have a Class of Company which has User pointers. The query I want on Company class is like this:

Retrieve Company rows where User object has a name equal to 'ABC'

So, how should I form this query ?

var Company = Parse.Object.extend("Company");
var query = Parse.Query(Company);

query.equalTo("name")       ????

Is it possible to write such a request in a single query ? Thanks.

You'll need to query for the User first based on the name of "ABC". Then in the success callback of that query, do the query on your Company table using the objectId returned from the User query. Something like this:

var userQuery = Parse.Query('_User');
var companyQuery = Parse.Query('Company');

userQuery.equalTo('name', 'ABC');

  success: function(user) {
    var userPointer = {
      __type: 'Pointer',
      className: '_User',
      objectId: user.id

    companyQuery.equalTo('user', userPointer);

      success: function(company) {
        // WHATEVER
      error: function() {
  error: function() {

How-To Use Pointers/Relations, Object.extend("Posts"); var query = new Parse.Query(Posts);. What we just did is set up a query for our JavaScript code to talk to our Posts class  var Posts = Parse.Object.extend("Posts"); var query = new Parse.Query(Posts); What we just did is set up a query for our JavaScript code to talk to our Posts class. query.include("postAuthor"); This line of code is what allows us to get the information from the user entry to postAuthor is "pointing" to without doing another query.

You can use an inner query:

var Company = Parse.Object.extend("Company");
var mainQuery = Parse.Query(Company);

var UserObject = Parse.Object.extend("User");
var innerUserQuery = new Parse.Query(UserObject);
innerBankQuery.equalTo("name", "ABC");
mainQuery.matchesQuery("bank", innerBankQuery);

var ansCollection = mainQuery.collection();
        success: function(results) {
         // Do whatever ...

How to Query Based on a Pointer on Parse Server, Instead, you need to create a pointer object and use it in the query. var visitQuery = new Parse. Query('Visit'); visitQuery. equalTo('user', { "__type": "Pointer", "className": "_User", "objectId": userId }); return visitQuery. Similarly to non-array pointers, you can eagerly fetch all of the elements in that array: myQuery.include("arrayOfPointersCol"); // but be careful, keep array lengths short Underscore. Last, and unrelated to the array or pointer ideas, you certainly can map an array of object ids, transforming them into an array of pointer objects.

I should say the query will be...

const userQuery = Parse.Query('_User');

userQuery.equalTo('name', 'ABC');

userQuery.find().then((user) => {

    const companyQuery = Parse.Query('Company');

    companyQuery.equalTo('user', {
      __type: 'Pointer',
      className: '_User',
      objectId: user.id

    companyQuery.find().then((company) => {

JavaScript Developers Guide, Parse.Query.find() returns Parse.Pointer[] instead of Parse.Object[] #5521 Apr 17, 2019 · 41 comments · May be fixed by parse-community/Parse-SDK-JS#924. The query I want to do is find all of the messages for a recipient. So I need to include the message in the MessageRecipients query but I would also like to include the nested User and Activity objects. var MessageRecipient = new Parse.Query('MessageRecipient'); messageQuery.equalTo('recipient', query.recipient); messageQuery.include('message');

Assuming Your Company collection has a field called User and User collection has a name field, then you can search for Company with user name through companyQuery.equalTo("User.name");

This works in Parse 2.1.0

Parse.Query.find() returns Parse.Pointer[] instead of Parse.Object , Hello, I have one question about query object Example my data has field "​students" type as array pointer of "student" class students [ {"__type": "pointer", @sonysm https://docs.parseplatform.org/js/guide/#using-arrays Pointers are stored as objects in Parse database, so if you try to compare a string to an object with query.equalTo() function, nothing will be found. This is how pointers are stored: { __type: 'Pointer', className: '_User', objectId: user-object-id }

How to query object contain in field type array of pointer? · Issue , I added a row. In my javascript code I try a simple query by objectId but I'm getting empty results: var MyClass = Parse.Object.extend("MyClass"); var query = new  Parse query then state change after resolve. angularjs,parse.com,angularjs-factory,angularjs-ui-router,angularjs-promise. You should inject currentRestaurantService dependancy first before using it in resolve currentRestaurant function.

Parse.com Querying for object containing array of pointers not , equalTo("playerId", pid); query.first({ success: function (object) { var playerPtr = new Parse.User(); playerPtr = object; newFollowRelationship.set("playerPointer",​  Issue Description. When running a simple query on a class from cloud code, the result is an array of pointers to class objects instead of an array of actual objects.When the same query is run on the client it works ok.

How to save parse User object into pointer field of - javascript, In his Post class he has a column set to be a Pointer that points to the _User class​. However, when he tried to use the standard query equalTo() method and the dot​  In many cases, get isn’t powerful enough to specify which objects you want to retrieve. Parse.Query offers different ways to retrieve a list of objects rather than just a single object. The general pattern is to create a Parse.Query, put conditions on it, and then retrieve an Array of matching Parse.Objects using find.

  • Hi, thanks for answering.. I asked because I needed to know if this is possible in a single query.. Similar to inner queries in MySql.
  • It's very awkward to have to create a pointer element, but that does work. Thank you for this.
  • What is innerBankQuery in your example?