minmongo not being updated by PG update?
Closed this issue · 3 comments
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.
Are you able to fix?
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.
OK, this was the result of my misunderstanding of the minimongo API.