MongodB 'save' command not supported in MeteorJS?


#1

Was following MongodB tutorial.

in lib/collections.js:

FutureTasks = new Meteor.Collection('future_tasks');

var Schemas = {};

Schemas.FutureTask = new SimpleSchema({
    ticketnumber: {
        type: String,
        label: "TICKET_NUMBER",
        max: 10, 
        index: true,
        optional: true, 
        unique: true
    },

in server/main.js:

for (var i = 0; i < recordsLength; i++) {

    FutureTasks.save({

Exception in callback of async function: TypeError: Object [object Object] has no method ‘save’

But only works with ‘insert’, and hi-lighting ‘save’ shows multiple implementations, so why is ‘save’ is not recognized within MeteorJS environment?


#2

Can you use upsert instead?

Alternatively, you could make use of raw collection methods on the server, which do have the save method.


#3

Thanks Rob, will try that.

I am using a cron job that will continuously do a GET HTTP and will either insert (first time loop is run) or update (loop running for the second time if there are any changes) but if any are no changes, upsert will be happy to do nothing?