meteor / postgres-packages

Early preview of PostgreSQL support for Meteor (deprecated, here for historical reasons)
http://meteor-postgres.readthedocs.org/
158 stars 25 forks source link

minmongo not being updated by PG update? #43

Closed marcmunro closed 8 years ago

marcmunro commented 8 years ago

I have a simple counter updated by the following code when a button is pressed:

var count = curCount(pk)
Buttons.update({count: count + increment}).where({id: pk}).run()

My button (hacked from the default meteor app) looks like:

<template name="hello">
  <button>Click Me</button>
  <p>You've pressed the button {{counter}} times.</p>
</template>

And my helper for hello is:

Template.hello.helpers({
  counter: function () {
    var res = Buttons.select().where({id:1}).fetch()
    console.log('COUNTER====================')
    console.log(res)
    return res[0]? res[0]['count']: undefined
  }
});

When I click on the button, I see a definite flicker as the counter first shows an empty value and then catches up with the value from the database. My client-side console log looks like:

"COUNTER===================="
Array [  ]
"COUNTER===================="
Array [ Object ]

So, am I using the wrong method to fetch from my Buttons table, or is the minimongo state not being updated in line with the server?

I can provide the full code if needed.

yoonghm commented 8 years ago

Are you able to fix?

marcmunro commented 8 years ago

Not so far. I'm still trying to understand what is going on - I'm new to Meteor. I plan to spend today looking into this in more detail. I'll report back.

marcmunro commented 8 years ago

OK, this was the result of my misunderstanding of the minimongo API.