couchbase / couchbase-lite-ios

Lightweight, embedded, syncable NoSQL database engine for iOS and MacOS apps.
Apache License 2.0
1.62k stars 297 forks source link

View query with array of keys doesn't return rows in same order #88

Closed snej closed 10 years ago

snej commented 11 years ago

Begin forwarded message:

From: Darren Kin Wah Lai Subject: Row return not in the order of keys Date: August 2, 2013 at 1:47:55 AM PDT To: mobile-couchbase@googlegroups.com

Hi All,

I have a problem here. I have a few documentId and i want to get the document. And i want the result in the order of keys (documentId) that i set. Example: CBLQuery* query = [[self.database viewNamed: @"allDocument"] query]; query.keys = @["B7389610-FA8D-4DCD-AE82-36248E6A9524","C4DA93B6-DE27-4150-8519-B3E3C234D0EA","08B87613-42FB-463C-9858-DD0E0D8DF694"];

However, the result i receive is not in that order. So i wonder how can i achieve this?

snej commented 11 years ago

Note that in this particular case you can just write a for loop that calls -documentWithID: to get the docs.

jessliu commented 10 years ago

There appears to be a best practice for this specific issue. Closing this out as part of bug scrub, but please re-open if issue persisting.