-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmongo.js
44 lines (28 loc) · 865 Bytes
/
mongo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import mongoose from 'mongoose';
import { MongoClient } from 'mongodb';
const client = MongoClient.connect(uri,(err,db)=>{
if (err) throw err;
const dbo = db.db("articalDB")
const result = dbo.collection("uss").find({password:"a"})
console.log(result)
});
/*
const collections = await db.listCollections().toArray();
const collectionNames = collections.map(c => c.name);
console.log(collectionNames);
const collectionName = 'uss';
const collection = db.collection(collectionName);
console.log(collection.findOne({},(err,result)=>{
if(err) throw err;
console.log(result);
}))
MongoClient.connect(url, function(err, db) {
if (err) throw err;
var dbo = db.db("mydb");
dbo.collection("customers").findOne({}, function(err, result) {
if (err) throw err;
console.log(result.name);
db.close();
});
});
*/