javascript - How to store cost data in Meteor JS so it can be incremented? -


I have a list of services that meet the associated cost and time to complete the service when I have them in the database The object looks like this:

  Cost: "1" name: "vaginal" time: "10"  

I believe That the surrounding brackets of numbers are not allowing my app to increase these objects when I call them in the Meteor Method.

I keep on continuing to include this error:

  & gt; Error class {Stack: "Error: m (anonymous function) (http: // localh ... 7f11e3eaafcbe13d80ab0fb510d25d9595e78de2: 3735: 17)", Error: 409, Reason: "Minimongoirerroyer: $ Ink modifier not applied to non-number " 

The services are added using this function:

  Meteor.methods ({createService: function (postAttributes) {var user = Meteor.user (); // Make sure the user is logged in (! Users) enter the new meteorite. Error (401, "You will find new stories. Need to log in to ST "); // Make sure the post's title is (if! PostAttributes.name) new metric. Error (422, 'Please fill in a name'); // Make sure that the service Put a new metric (if! PostAttributes.cost). Error (422, 'Please fill a value'); // Make sure the post is a title if (! PostAttributes.time) new Meteor.Error (422) , 'Please fill in at a time'); console.log (postAttributes); // chooses whitelisted keys var po St = _.extend (_. (Post Properties, 'Name'), {cost: postAttributes.cost, Time: Post Properties Es.time, userId: user._id, Author: user.emails [0]. Address, Presented: New Date () GetTime ()}); Var postId = Services.insert (post); Return post id; }});  

I am increasing using this function:

  appointment.update (postAttributes.appointmentId, {$ inc: {"appointmentTotal": service .cost}});  

Instead of a string, I'm completely lost in getting the cost and time for services in number format.

OK, as you said, it looks like you have to convert your strings into an integer: var post = _.extend (_.) (PostViewView, 'name'), {cost: parseInt (postAttributes.cost), time: ParseInt (postAttributes.time), userId: user._id, Author: user.emails [0]. Address, Submitted: New Date () GetTime ()});


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -