1.利用游标方式
var lst = 查询语句
while(lst.hasNext()) db.新表名.insert(lst.next());
var lst = db.getCollection("article_xjhw").aggregate({
$lookup: {
from: "issue_xjhw",
localField: "request_url",
foreignField: "url",
as:"title"
}
})
while(lst.hasNext()) db.t2.insert(lst.next());
2.aggregate $out
管道操作符
$out参数是新表名
db.getCollection("article_xjhw").aggregate([{
$lookup: {
from: "issue_xjhw",
localField: "request_url",
foreignField: "url",
as:"title"
}
},{
$out: 'results'
}])
网友评论