-
Notifications
You must be signed in to change notification settings - Fork 0
/
ensureIndex.js
43 lines (40 loc) · 1.09 KB
/
ensureIndex.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
var MongoClient = require('mongodb').MongoClient; // Driver for connecting to MongoDB
var ObjectID = require('mongodb').ObjectID;
var dbConn;
MongoClient.connect('mongodb://localhost:40000/eposro', function(err, db) {
if (!err) {
dbConn = db;
console.log("Connected Successfully");
} else {
console.log(err);
}
});
setTimeout(function() {
dbConn.collection('vendors').ensureIndex({
"address.location": "2dsphere"
}, function(err, res) {
if (!err) {
console.log(res);
}
});
dbConn.collection("gs1cats").createIndex({
"id": 1
},
{unique:true},
function(err, res) {
if (!err) {
console.log(res);
}
}
);
dbConn.collection("gs1subcats").createIndex({
"id": 1
},
{unique:true},
function(err, res) {
if (!err) {
console.log(res);
}
}
);
}, 5000);