I'm creating a Meteor App using this boilerplate.

I'd like to insert some data into MongoDB from the client-side, and then use this data in html files.

However, the Meteor app does not seem to connect client Mongo (minimongo) with server-side (MongoDB). If I try a {CollectionObj}.insert command in the client-side repository, the data does not get written to MongoDB. I checked the collection with meteor mongo command, but there is no new data.

So, I wrote the below code on the server-side. (Contracts collection is defined in a separate file.)

  'insert_contracts': function(address, price, amount, exeday, premium, position, contract_address, abi){
       seller: address,
       price: price,
       amount: amount,
       exeday: exeday,
       premium: premium,
       position: position,
       contract_address: contract_address,
       abi: abi

And I wrote this on the client-side:

Meteor.call('insert_contracts', address, price, amount, exeday, premium, position, contract_address, abi);

So I have implemented an insert function, but I want to change it into a simple implementation using only client-side code.

I also have a problem with the find function.

On the server I have tried:

'find_contracts': function(){
  return Contracts.find({});

Then called it from client-side:

'click .btn-success': function(event) {
   var hoge = Meteor.call('find_contracts');

But hoge was stil undefined.

What am I doing wrong?

  • Can you please share the definition of your Contracts collection, which is defined in a separate file? You say you are using minimongo, which is designed to run client-side only with a mongodb API. Make sure you use a real mongo collection. I expect this to be the problem. – Jacob Eberhardt Apr 22 '16 at 9:39
  • This question seems to be better for StackOverflow -- it is not really an Ethereum/Solidity question but more a Meteor question. – JohnAllen Sep 6 '17 at 0:41
  • read more about subscribtions and publications – aleebek Nov 8 '17 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.