-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprepareGeoNYC.js
More file actions
54 lines (50 loc) · 1.42 KB
/
Copy pathprepareGeoNYC.js
File metadata and controls
54 lines (50 loc) · 1.42 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
49
50
51
52
53
54
/**
* Iterate through the artists in the database and
* add information such as biographies and news to them.
*/
var mongodb = require('mongodb');
//var mongoserver = new mongodb.Server('localhost', 26374);
var mongoserver = new mongodb.Server('10.112.0.110', 26374);
var dbConnector = new mongodb.Db('uenergy', mongoserver);
var count = 0;
dbConnector.open(function(err, db) {
if(err) {
console.log(err.message);
} else {
db.collection('artistLocations2',function(err,collection){
if(err){
console.log(err.message);
} else {
collection.ensureIndex({loc:'2d'},{min:200,max:1400, safe:true},function(err){
if(err)
console.log(err.message);
else{
/*collection.insert({pos:[600, 600]}, {safe:true}, function(err, result) {
if (err) console.log(err);
else console.log('worked');
});*/
cursor = collection.find({});
//global var
cursor.count(function(err, total) {
if(err) {
console.log(err.message);
} else {
cursor.each(function(err, artist) {
if(err) {
console.log(err.message);
} else if(artist != null) {
collection.findAndModify({'_id':artist._id}, [['_id','asc']],
{$set : {loc: Array(parseFloat(artist.x), parseFloat(artist.y))}},function(err){
if(err) console.log(err);
else{
count++;
if(count == total)
process.exit();
}
});
}
});
}});
}}); }
});}
});