1

I have read majority of the questions which quite havent helped me.

So I have three tables, User (parse Default), DataSet and Datapoint.

DataSet is linked to User based on Pointer.

Datapoint is linked to Dataset based on Pointer (object ID of DataSet).

I can easily load DataSets for each User Parse. What i would like to do is load datapoints for a dataset.

I am using Angular, and I can pass the dataset object to, and based of that ID I want to be able to get datapoints for that dataset.

He is what I have so far.

getmyDataPoint: function getMyDataPoint(dataset, callback) {

      //get object ID of dataset
      var datasetid = dataset.id;


      var query = new Parse.Query(Datapoint);
      query.include('inDataset');

     //inDataset is column name that is pointer, linking to dataset. 

      query.EqualTo('inDataset', datasetid);
      query.find({
          success: function(results) {
              callback(results);
              alert("found some here " + results);
          },
          error: function(error) {
              alert("Error: no datapoint found " + error.message);
          }
      });

As you would know this quite doesnt work. Any help?

4
  • You say you are using pointers, then you say you are using the ID directly. You would unlock more power of Parse if you use actual pointers. Commented Jan 12, 2015 at 5:45
  • I am using pointers, sorry if that wasnt clear. Commented Jan 12, 2015 at 5:47
  • In that case you should compare to the dataset object instead of its ID, as per my answer. Commented Jan 12, 2015 at 5:52
  • @smushi can you help me too with something very similar? Commented Oct 11, 2017 at 15:17

1 Answer 1

2

Lets assume you fix up your classes as follows:

DataSet class
  user: Pointer<User>
Datapoint class
  inDataset: Pointer<DataSet>

Now you can query for Datapoint rows where the inDataset column matches a DataSet quite easily:

query.equalTo('inDataset', dataset);

Under the covers Parse's SDK extracts the object ID and matches on that, but using an actual pointer makes other types of queries possible that you couldn't do with just the strings as you are currently doing it.

Sign up to request clarification or add additional context in comments.

1 Comment

oh, I feel so dumb. It was so simple.was almost there as well. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.