Hi community.
Can anyone advise me in the following issue
# create a collection
Posts = new Mongo.Collection 'posts'
# define a class
class Topic
constructor: (value) ->
{@name, @counts} = value
typeName: ->
'topic'
toJSONValue: ->
{@name, @counts}
clone: ->
new Topic {@name, @counts}
equals: (other = {}) ->
other?.name is @name
# register type
EJSON.addType, (value) ->
new Topic value
# client side
# insert - OK
Posts.insert {text: 'Hello', topic: new Topic('history', 0)}
# update with modifier - OK
Posts.update someId, $set: {text: 'Hello', topic: new Topic('history', 0)}
# update by replace document - OK
Posts.update someId, {text: 'Hello', topic: new Topic('history', 0)}
# server side
# insert - OK
Posts.insert {text: 'Hello', topic: new Topic('history', 0)}
# update with modifier - ERROR: Mongo error: notOkForStore
Posts.update someId, $set: {text: 'Hello', topic: new Topic('history', 0)}
# BUT! update by replace document - OK
Posts.update someId, {text: 'Hello', topic: new Topic('history', 0)}
I cant run update
on the server with modifier (like $set
), but it works without modifier.
So I dont mind the reason of that behaviour