Meteor-Community-Packages / Meteor-Community-Packages/ground-db

loadDatabase not working

Open
#207 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
569
Forks
77
PR merge metrics
No merged PRs in 30d

Description

Hi @raix

I am using groundDb in an exiting application.
Right now I am simply trying to ground `Meteor.users`:

```coffeescript
GroundedUsers = new Ground.Collection("Meteor.users")
GroundedUsers.observeSource(Meteor.users.find())
if Meteor.isCordova && Meteor.status() != 'connected'
GroundedUsers.loadDatabase()
```

The above did not work.
So, I tried overriding `find` and `findOne` method:

```coffeescript
Meteor.users.find = (args...) ->
GroundedUsers.find(args...)
Meteor.users.findOne = (args...) ->
GroundedUsers.findOne(args...)
```

Now, `Meteor.users.find({_id: Meteor.userId()}).fetch()` should return a document but it returns a plain object. I have apply `Collection._transform` to transform it into a document.

If `loadDatabase()` would be working, I should not have to do the same.

PS: Above code is written in [coffeescript](http://coffeescript.org/).

Any help would be nice.

Thanks

Contributor guide

Open the contributing guide

Research direction

Start by tracing Ground.Collection.loadDatabase() and how GroundedUsers.observeSource(Meteor.users.find()) populates the local collection. Reproduce the offline Meteor.users case from the issue, then compare the returned object with the expected transformed document; done means loadDatabase works without overriding find or findOne.

Written by the indexing model from the issue text.

Assessment

Tech stack
coffeescript, javascript
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.