使用Mongoose插入子文档

时间:2017-04-21 18:06:09

标签: node.js mongoose insert subdocument

我目前有一个架构:

     app.post('/apply',function (req,res){


    //hard coded for testing purposes       
User.update({id:mongoose.Types.ObjectId("58c2871414cd3d209abf5fc9"),"position._id":mongoose.Types.ObjectId("58d6b7e11e793c9a506ffe8f")},
              {$push:{"position.$.applied":{
                candidate_id:"test"

              }
            }

            }).exec(function (err, result) {
          console.log(result);
          res.send({result:result});
        });
        });

我正在尝试将数据插入“已应用”子文档中,但似乎无法使其正常工作。

我的职能:

from ftplib import FTP_TLS
import fnmatch
import os

ftps = FTP_TLS('myftp_site.com')
ftps.login('userxx', 'pwxx')
ftps.prot_p()
ftps.cwd('Inbox')

print("File list:")

list_of_files = ftps.retrlines("LIST")
dest_dir = "C:\DownloadingDirectory"

for name in list_of_files:
    if fnmatch.fnmatch(name,"StartingFileName*"):
        with open(os.path.join(dest_dir, name), "wb") as f:
            ftps.retrbinary("RETR {}".format(name), f.write)

ftps.quit()

    enter code here

出于某种原因,这不会为我插入任何东西,id也绝对是正确的。谁知道我哪里出错?

调试后返回: enter image description here

数据库: enter image description here

0 个答案:

没有答案