siwi-mongodb
v1.1.0
Published
nodejs 连接 mongodb
Downloads
2
Readme
siwi-mongodb
nodejs 连接 mongodb
const MongoDb = require('../index')
const url = 'mongodb://192.168.0.102:27017'
const db = 'siwi-wget'
const mongodb = new MongoDb(url, db)
const ObjectId = mongodb.ObjectId
class Test {
constructor() {
this.init()
}
async init () {
const mongo = await mongodb.MongoClient()
const coll = await mongo.collection('test')
const res = await coll.find({_id: ObjectId("5aa1841a4290b52ce4c53e66")}).toArray()
console.log(res)
}
}
module.exports = new Test()