Last active
December 30, 2015 18:09
-
-
Save dwinston/7865309 to your computer and use it in GitHub Desktop.
Failed attempt to reproduce the issue of http://stackoverflow.com/questions/20457474/meteor-collection-differs-on-server-and-client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
</head> | |
<body> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GameMaps = new Meteor.Collection('gameMaps'); | |
if (Meteor.isClient) { | |
Meteor.subscribe('allMaps'); | |
} | |
if (Meteor.isServer) { | |
Meteor.publish('allMaps', function() { | |
return GameMaps.find(); | |
}); | |
Meteor.startup(function () { | |
if (GameMaps.find().count() === 0) { | |
GameMaps.insert({ | |
name: 'foo', | |
structure: { | |
arg1: 'bar', | |
fields: [ | |
{name: 'someName', value: 'someValue'}, | |
{name: 'someOtherName', value: 'someOtherValue'} | |
] | |
} | |
}); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I call
GameMaps.findOne({name: 'foo'}).structure.fields[0]
from the client console and get{name: "someName", value: "someValue"}
This worked with and without the
autopublish
package.