Find and BackendlessCollection

Hello all,

Here is a simple question for which I can’t find answer here or in the documentation…
I would like to get ONLY one specific record in my table.

So I used Find() with a whereClause to do that. Easy.

But I am wondering if it must only return a BackendlessCollection? Is it possible to use Find() with a whereClause and just get a single object?

For sure I can make it with a BackendlessCollection and iterate to get the only one record I got… But maybe there is a better way…

Thanks for your answer!

If you search by objectId,you may use FindById() method which returns a single object. But if you use where clause, there’s no guarantee that there will be a single result, thus you have to use BackendlessCollection.

Vincent,

If this is a question of minimizing the payload, consider setting the paseSize query option to 1. The return value would still be BackendlessCollection, since the method signatures cannot change.

Mark

Hi Mark,

Actually I was even not looking for reducing the payload. I just thought during coding there maybe must be something for only one record.

Just a technical question to die a little bit less stupid than yesterday :0) :0)

Thanks for your answer as usual!