【问题标题】:Collection error in `MeteorJs`?`MeteorJs` 中的集合错误?
【发布时间】:2014-02-26 17:04:33
【问题描述】:

我需要帮助,因为我在Collection 中插入日期,但出现了找不到方法错误。如何解决该错误请帮助我,下面是我的代码。

My Collection Name is : hcare_user = new Meteor.Collection('hcare'); 
Js code :
hcare_user.insert({
                         userid: userid, 
                         firstname : firstname,
                         lastname : lastname,
                                 bday: bday, 
                         bmonth : bmonth,
                         byear : byear,
                         phoneno:phoneno,
                         address : address,
                         city : city,
                         state:state,
                         zipcode: zipcode,
                         country : country,
                         ssn : ssn,
                         permissions:permissions
                          }
                     , function( error, result) 
                      { 
                        if ( error ) console.log ( "error ="+ error); //info about what went wrong
                        if ( result ) 
                        {
                            console.log ( "result="+result );//the _id of new object if successful
                            $('input[type="text"]').val('');
                            //$('input[type="radio"]').val('');
                            //$('input[type="date"]').val('');
                            alert("Sucessfully Created");
                                          }                 
                                    });
                                 }
                                 });

错误是:

error =Error: Method not found [404] @ 

【问题讨论】:

    标签: meteor


    【解决方案1】:

    此错误通常是由于未能在服务器上声明集合造成的。此行是否出现在同时在客户端服务器上运行的代码中?

    hcare_user = new Meteor.Collection('hcare');
    

    如果没有,您需要将其放在clientserver 目录之外的文件中,从而在这两个目录以及Meteor.isServerMeteor.isClient 块之外运行。

    如果您只想要一个本地集合(即仅客户端),您可以将其更改为 hcare_user = new Meteor.Collection(null),这也应该清除错误(尽管显然您不会以这种方式在持久存储中插入任何内容)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-29
      • 2016-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多