1

我是 Cosmos Db 的新手。当我尝试通过 mongoose 查询 Azure Cosmos db 模拟器时,我得到了 null。但是,如果我查询托管在 Azure 上的 Cosmos Db,一切正常。我不知道我的代码有什么问题。知道问题可能是什么以及如何解决这个问题

在此处输入图像描述

这是我的代码

var mongoose = require('mongoose');
var schema = mongoose.Schema(
    {
        "id": String,
        "status": String,
        "owner": String,
        "sn": String
    }

);
schema.set('toJSON', {
    virtuals: true,
    transform: (doc, ret, options) => {
        delete ret.__v;
        delete ret._id;
    },
});
module.exports = mongoose.model('projects', schema);

var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:10255/picassoData?ssl=true',  
    { 
        useNewUrlParser: true,
        auth: {
            user: "localhost",
            password: "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
          }
    });

var Projects = require('./project');
var x = await Projects.findOne({id: "123"}).exec();
4

0 回答 0