使用NodeJS,MongoDB和Amp更新数组项僧 [英] Updating an array item using NodeJS, MongoDB & Monk

查看:154
本文介绍了使用NodeJS,MongoDB和Amp更新数组项僧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的数据集:

I have a data set like this:

{ 
  name : 'Doc Name',
  photos: [
      {
        name: 'photo1',
        url: 'http://.....'
      },
      {
        name: 'photo2',
        url: 'http://......'
      }
   ],
   etc ...

使用僧侣 https://github.com/LearnBoost/monk 如何更新photo2?我现在可以在遍历字段时使用索引.

Using Monk https://github.com/LearnBoost/monk how do I update photo2? I can use an index as I am iterating over the fields at the moment.

我目前在下面的尝试给我一个错误,并且我不能为JSON选择器使用变量(如在索引中).

My current attempt below gives me an error, and I can't use a variable for the JSON selector (as in the index).

collection.update({_id: data._id}, {photos[i].data: filename}, function(err, updatedata) {

            });

推荐答案

可以使用位置

这篇关于使用NodeJS,MongoDB和Amp更新数组项僧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆