且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在MongoDB更新语句中使用变量

更新时间:2022-12-27 19:52:14

您可以这样做:

'blur .editable' : function () {
  var target = event.currentTarget.value;
  var field = event.currentTarget.name;

  var obj = {};
      obj[field] = target;
  Hostings.update( { _id: this._id },{ $set: obj } );
}

可以通过两种方式访问​​Javascrip对象:

Javascrip objects can be accessed two ways:

object.attribute

object["attribute"]

如果使用第二种方法,则可以使用变量访问它

if you use the second method you can access it with a variable