Getting a error inserting in to a Meteor Collection

前端 未结 2 1536
天涯浪人
天涯浪人 2021-01-05 05:39

I am starting to work with Meteor and I am running in to my first issue. I am trying to insert a item in to my collection. I get the below console log error. Can someone hel

相关标签:
2条回答
  • 2021-01-05 06:10

    When you try Video.insert. Meteor is trying to insert both on the client and on the server as well. Meteor design it this way to help reflect the change instantly on the client(Latency Compensation).

    When your Video collection is not defined on the server (not in Meteor.isServer wrap or file that can accessed by Server). It will throw the error you encountered.

    If you want to insert to client only. You can access to it by _collection. So your insert statement would be Videos._collection.insert(values);

    You can find more info here in this screen cast: http://www.eventedmind.com/feed/meteor-anatomy-of-a-collection-insert

    0 讨论(0)
  • 2021-01-05 06:18

    To create a local-only collection:

    MyLocalCollection = new Collection(null);

    (reference doc here)

    About "_collection":

    _collection is an undocumented property that behaves strangely in many cases. You might prefer not to use it.

    About manipulating only the local cache of a client-server collection:

    There is no way to do this directly. However, it is very easy to create a dynamic local mirror of an existing collection (in my experience, this is the way to go for any complex UI). See this post.

    0 讨论(0)
提交回复
热议问题