Skip to content
This repository has been archived by the owner on Aug 22, 2019. It is now read-only.

Sorting a collection #23

Closed
ashmore11 opened this issue Mar 21, 2016 · 2 comments
Closed

Sorting a collection #23

ashmore11 opened this issue Mar 21, 2016 · 2 comments

Comments

@ashmore11
Copy link

Hi There,

I can't seen to find a way of sorting my collection. I know collection.sorted returns all the values in my collection, sorted by id, but I would like to sort using another field in my collection.

Is there a built in way of doing this?

Thanks!

@siegesmund
Copy link
Owner

No, there is not. This is intentional. MeteorJS is tied to MongoDB on both the client and server. There's nothing approximating MongoDB in iOS, and for serious applications you'll really want to use Core Data, Realm, SQLite or perhaps Couchbase Mobile as your iOS datastore. In this more advanced scenario, SwiftDDP would handle the communication - method calls, pubs and subs - between your client and your mobile datastore. You can see examples of this in the Todos examples.

MeteorCollection is intended to provide scaffolding to create more powerful collections backed by other datastores by providing a built-in object that responds to server changes. While it has a few convenience methods, it's not a full-fledged client datastore like minimongo.

That said, what you're trying to do is super easy. Just subclass MeteorCollection and add a method that does what you're trying to do. Have a look at the MeteorCollection code to get an idea of how it works. It's really not complicated.

@ashmore11
Copy link
Author

Ok thanks @siegesmund, I'll give it a go today : ) thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants