Meteor - insert failed: Method not found

后端 未结 2 1825
攒了一身酷
攒了一身酷 2021-01-14 03:17

I have a problem with my Meteor\'s JS file. I get this error \"insert failed: Method not found\" when I try to insert any data to the database and reflect on chart. I\'ve tr

2条回答
  •  温柔的废话
    2021-01-14 03:58

    While following the Getting Started tutorial on the official meteor.js website I've had the same problem with autopublish turned on.

    Turned out the issue was I created my Tasks collection inside the imports/ folder. Thus it was not implicitly imported on the server.

    I had to explicitly import it on the server to solve the issue.

    server/main.js

    import { Meteor } from 'meteor/meteor';
    import '../imports/api/tasks.js';
    
    Meteor.startup(() => {  
      // code to run on server at startup
    });
    

    As you can see the import is not used by my code but is required anyways.

提交回复
热议问题