Ver Mensaje Individual
  #3 (permalink)  
Antiguo 25/08/2014, 16:29
andres18281
 
Fecha de Ingreso: febrero-2013
Ubicación: Cali Colombia
Mensajes: 118
Antigüedad: 11 años, 2 meses
Puntos: 0
Respuesta: Problema en Node.js

Carlangueitor el codigo anterior tiene un problema, fijate por favo en este script.

En una coleccion en el campo State hay dos registros "California" y "Vermont" donde debo agregar un campo "month_high" : true a los registros que tengan el puntaje
mas alto en el campo Temperature pero el error lo marca en el throw e

Código Javascript:
Ver original
  1. var MongoClient = require('mongodb').MongoClient;
  2. MongoClinet.connect('mongodb://127.0.0.1:27017/weather',function(err,db){
  3. if(err) throw err;
  4.         var a = -1 ;
  5.         var coleccion = db.collection('data');
  6.         var cursor = coleccion.find();
  7.              for(var i = 1;i <= 2;i++){
  8.                 cursor.sort([["Temperature",-1],["State",a]]).limit(1);
  9.                 var myupdate = {$set:{"month_high" : true},{multi:true}};
  10.                 var filter = {"State":cursor.State};  
  11.                 db.data.update(filter,myupdate,function(err, updated) {
  12.                         if(err)throw err;
  13.                         console.dir("Successfully updated " + updated + " document!");                
  14.                 });
  15.                 a = 1;
  16.               }
  17.        db.close();
  18. }

El error es el siguiente aunque en el codigo anterior tambien muestra el mismo error:
Código Javascript:
Ver original
  1. node.js:201
  2.         throw e; // process.nextTick error, or 'error' event on first tick
  3.               ^
  4. SyntaxError: Unexpected token {
  5.     at Module._compile (module.js:429:25)
  6.     at Object..js (module.js:459:10)
  7.     at Module.load (module.js:348:32)
  8.     at Function._load (module.js:308:12)
  9.     at Array.0 (module.js:479:10)
  10.     at EventEmitter._tickCallback (node.js:192:41)
  11. usuario@usuario-desktop:~/Dropbox/Mongodb$ node test2_2.js
  12.  
  13. /home/usuario/Dropbox/Mongodb/test2_2.js:9
  14.         var myupdate = {$set:{"month_high" : true},{multi:true}};
  15.                                              ^
  16.  
  17. node.js:201
  18.         throw e; // process.nextTick error, or 'error' event on first tick
  19.               ^
  20. SyntaxError: Unexpected token {
  21.     at Module._compile (module.js:429:25)
  22.     at Object..js (module.js:459:10)
  23.     at Module.load (module.js:348:32)
  24.     at Function._load (module.js:308:12)
  25.     at Array.0 (module.js:479:10)
  26.     at EventEmitter._tickCallback (node.js:192:41)