How to check Collections.insert() is Successfully Inserted or not in Meteor?
collections, meteor
Solution
Insert provides a server response in the arguments to a callback function. It provides two arguments 'error' and 'result' but one of them will always be null depending on whether the insert is successful.
Client.insert( { name: "xyz", userid: "1", care:"health" }
, function( error, result) {
if ( error ) console.log ( error ); //info about what went wrong
if ( result ) console.log ( result ); //the _id of new object if successful
}
);
See documentation for more info.
Problem
How to check(user created collections) Collections.insert() is Successfully Inserted or not in `Meteor JS`?. For example I am using the Client Collections to insert details as shown below: ``` Client.insert({ name: "xyz", userid: "1", care:"health" }); ``` How to know the above insert query is successfully inserted or not?. Because of the below problem ``` If the form details are successfully inserted - do one action else -another action ``` So Please suggest me what to do?