Client document insert, insert failed: Method '/streams/insert' not found


#1

Hi,

Inserting my apps on the client works well. (Object array from REST service)
now, I also want to put my “streams” in another collection (same as above but other business meaning)

The log shows no error, I see the documents also flashing in the screen, but then they are removed and get this strange error

insert failed: Method '/streams/insert' not found

but I just do the same as with the apps insertion (works fine), but now for the streams collection it does not work

My code is

var updateAppsCollection = function(){
// set Session variable in method callback
Meteor.call('getApps', function(error, docList){
 if(error){
  console.error(error);
}
else{
  // console.log('try to insert document array into mongo, first delete all current data in mongo apps table');
  // Delete all existing apps from database
  Apps.find().forEach(function(app) {
    Apps.remove(app._id);
  });

  //insert all docs into the database
  docList.forEach(function(doc) {
   Apps.insert(doc);
 })
}
})

console.log('insert streams in collection');
Meteor.call('getStreams', function(error, docList){
  console.log('insert streams', docList);
  docList.forEach(function(s){
    Streams.insert(s);
  })

});

};

my helpers and imports

import { Template } from 'meteor/templating';
import { Customers } from '../api/customers.js';
import { Session } from 'meteor/session';
// import * from '/lib/globalHelpers.js';

import './body.html';
import {Apps} from '/imports/api/apps.js'
import {Streams} from '/imports/api/streams.js'
import './customer.js';
import moment from 'moment';
import lodash from 'lodash';

_ = lodash;

Template.body.helpers({
  customers() {
    return Customers.find({}, { sort: { createdAt: -1 } });
  },
  apps(){
    //return Session.get('qApps'); 
    return Apps.find();
  },
  streams(){
    return Streams.find();
  },
  countStreams(){
    return Streams.find().count();
  },
  countApps(){
    return Apps.find().count();
  },
  formatDate (date) {
    return moment(date).format('DD-MM-YYYY');
  }
});


#2

ah! that’s what you get with meteor 1.3 import.

I only imported my new collection on the client and not the server. So I also had to add

import { Apps } from '/imports/api/apps.js';

It was meteors latency compensatoin mechanism that causes the flashing because the server could not insert it on his side…

But why is this? because I don’t do anything on the server side with this streams collection… The only thing I can imagine is that Meteor has to know of its existance on the server too… Normally you would put this in the lib folder in 1.0