Search code examples
parse-platform

Parse Server - Get Pinned Object using Labels


I am storing objects in the Local Datastore via Pinning. I can pin objects under a label (e.g. following). If I want to return all of the people that a user is following there doesn't seem to be a way to do that. I can't even find a way to return all pinned objects regardless of their label. Am I missing something?

Here is my code for storing a person object in my Local Datastore:

peer.pinWithName( 'Followed' );

I can find out if the peer is followed using:

const Followed = Parse.Object.extend( 'Peer' );
const query = new Parse.Query( Followed );
query.fromLocalDatastore();
response = await query.get( peer.id );

Solution

  • Querying all objects from local data store

    const Followed = Parse.Object.extend('Peer');
    const query = new Parse.Query(Followed);
    query.fromLocalDatastore();
    response = await query.find();
    

    Reference: https://docs.parseplatform.org/js/guide/#querying-the-local-datastore

    Querying an object from pin with name

    const Followed = Parse.Object.extend('Peer');
    const query = new Parse.Query(Followed);
    query.fromPinWithName('Followed');
    response = await query.get(peer.id);
    

    Querying all objects from pin with name

    const Followed = Parse.Object.extend('Peer');
    const query = new Parse.Query(Followed);
    query.fromPinWithName('Followed');
    response = await query.find();
    

    Reference: http://parseplatform.org/Parse-SDK-JS/api/2.7.0/Parse.Query.html#fromPinWithName