Tag: mongoose

Mongoose:[36mDB连接错误:MongoError:在复本集中找不到主节点

[36mDB connection error: MongoError: no primary found in replicaset[39m 0|product- | Unhandled rejection MongoError: no primary found in replicaset 0|product- | at /opt/source/node_modules/mongodb-core/lib/topologies/replset.js:524:28 0|product- | From previous event: 在通过Kubernetes在AWS上设置的有状态。 这是K8S文件中的URLconfiguration: – name: MONGODB_URI value: mongodb://mongo-0.mongo,mongo-1.mongo,mongo-2.mongo:27017/saveup-product-api?replicaSet=database

创build一个包含数组types的mongoose模型将会返回未定义的docker容器中的数据

我有一个mongoose模型包含2个属性数组的string和其他一些: var Model = new Schema({ _id: {type: Number, required: true, unique: true}, name: {type: String, required: true}, oneList: [String], anotherList: [String] }); 我创build模型: var model = new Model({ _id: 1, name: 'model', oneList: ['a', 'b'], anotherList: ['c', 'd'] }) 但是当我检查模型时,所有的列表都是未定义的: model._doc === { _id: 1, name: 'model', oneList: undefined, anotherList: undefined } 我尝试了一些变化: 将模型定义从[String]更改为[] […]

有Node.js的MongoDB在Docker中运行,但在Windows上不运行

问题 我遇到了类似于死锁的行为,我们的Node.js服务器应用程序对MongoDB实例运行了集成testing。 我们的testing代码和服务器代码都使用Mongoose和node.js驱动程序来访问MongoDB。 testing框架将删除数据库,并在每个testing套件开始时重新创build每个集合的索引(有时也可以是单个testing)。 这在testing过程中会发生很多次。 类似死锁的行为似乎在对db.collection.ensureIndex的一系列调用中发生。 一旦发生这种情况,所有执行都会停止,直到testing超时过期,这会中止testing。 如果我没有超时运行testing,挂起似乎是永远。 在这一点上,我觉得自己正在fla and,很想听到关于debugging方法或寻找线索方向的build议。 非常感谢。 细节 根据MongoDB并发常见问题解答 , ensureIndex在调用时不需要background:true选项ensureIndex需要一个独占的数据库写锁('W')。 不过,我已经通过Mongoosedebugging日志validation了background:true在这些调用中使用了background:true ,例如: mails.ensureIndex({ expires: 1, mailType: 1, readOn: 1 }) { background: true } 但是,MongoDB日志出现(至less对我来说)表明一个独占锁试图: command: createIndexes { createIndexes: "mails", indexes: [ { name: "expires_1_mailType_1_readOn_1", key: { expires: 1, mailType: 1, readOn: 1 }, background: true } ], writeConcern: { […]

docker工人 – 组成mongoose

我是Docker的新手,我正在尝试使用docker-compose进行最简单的设置,但是没有成功连接到Mongodb。 我的docker-compose.local.yaml文件: version: "2" services: posts-api: build: dockerfile: Dockerfile.local context: ./ volumes: – ".:/app" ports: – "6820:6820" depends_on: – mongodb mongodb: image: mongo:3.5 ports: – "27018:27018" command: mongod –port 27018 我的Docker文件: FROM node:7.8.0 MAINTAINER Livefeed 'project.livefeed@gmail.com' RUN mkdir /app VOLUME /app WORKDIR /app ADD package.json yarn.lock ./ RUN eval rm -rf node_modules && \ yarn […]