Start a new topic

Query works for one field, but not for the other?

Have a strange problem when querying for an entity. I'm trying to query on "topic_id" (which is a valid field), but DataStore.find() does not return it.

Here's the row:

And my query that doesn't

var subTopicsQuery = new $kinvey.Query();

subTopicsQuery.equalTo('topic_id', '5333298a24aabbb96746ad47');

return $kinvey.DataStore.find('subtopics', subTopicsQuery); // returns []

And the query that does:

var subTopicsQuery = new $kinvey.Query();

subTopicsQuery.equalTo('name', 'UX Lead');

return $kinvey.DataStore.find('subtopics', subTopicsQuery);

I'm replacing 5333298a24aabbb96746ad47 dynamically in my app, but it doesn't work harcoded either.

Did you try running the query in the console API and see if it works there?

It sounds like "topics" is a collection, any reason you aren't just using relations / kinveyRefs for this?
It looks like the `topic_id` is saved as a *ObjectID* instead of string. How did you create these particular documents?

If you saved them through BL, I recommend using the [collectionAccess.objectID]( method to make sure the value is a string, and not an object.

We are aware of the confusion around Object IDs / strings, and we are in the process of moving to strings only. So, in the future, this won’t be a problem anymore.
OhmzTech, you're definitely right. I should use relations, but figured I'd try it this way first.

Mark, I'll give that a shot.
To your point OhmzTech: how would I structure the KinveyRefs when I'm using custom BL? I don't see any modules that let you do that from the server side - unless I'm missing something.
Login or Signup to post a comment