-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
executable file
·48 lines (36 loc) · 1.08 KB
/
test.js
File metadata and controls
executable file
·48 lines (36 loc) · 1.08 KB
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
45
46
47
48
var MongoClient = require('mongodb').MongoClient;
async function fetchDatabase() {
console.log('fetch database called');
let client, db;
const databaseURL = 'mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb';
const database = 'Task';
const collection = 'taxi_data_new_1';
try {
client = await MongoClient.connect(databaseURL, {
useUnifiedTopology: true,
useNewUrlParser: true
});
db = client.db(database);
let dbCollection = db.collection(collection);
const geoQuery = {
loc: {
$geoWithin: {
$box: [
[-73.02823925018312, 40.73610423919209],
[-74.95957469940187, 40.7640963068463]
]
}
}
}
dbCollection.createIndex({ loc: "2dsphere" });
let queryResult = await dbCollection.find(geoQuery, {loc:1}).hint("loc_2dsphere").explain();
console.log(queryResult.queryPlanner);
console.log(queryResult);
// console.log(queryResult.length);
// dbCollection.dropIndexes();
}
catch (err) { console.log(err); }
}
async function test() {
}
fetchDatabase();