标签 mongodb 下的文章

以前的写法是这样的,

from pymongo import MongoClient
client = MongoClient(host='127.0.0.1')
db = client['dbname']
db.authenticate(user, password)

不过上面的已经废弃

warning:: Starting in MongoDB 3.6, calling :meth:authenticate
invalidates all existing cursors. It may also leave logical sessions
open on the server for up to 30 minutes until they time out.



- 阅读剩余部分 -

version: '3.1'

services:

  web:
    build: .
    restart: always
    ports:
      - 8080:80
    environment:      
      MONGODB_HOST: mongodb
      MONGODB_USER: root
      MONGODB_PWD: 123456
    depends_on:
      - mongodb

  mongodb:
    image: mongo:4.1
    restart: on-failure
    ports:
      - 27017:27017
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: 123456
    volumes:
      - ./data/mongo:/data/db
      - ./data/mongo-entrypoint/:/docker-entrypoint-initdb.d/

- 阅读剩余部分 -

官方文档的解释:
Existence Check

The { item : { $exists: false } } query matches documents that do not contain the item field:

db.inventory.find( { item : { $exists: false } } )

Studio3T里的Query查询条件可以是 {downloaded:{$exists: false}} 即可以查出那些没有这个downloaded字段的数据