-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_dates.js
More file actions
65 lines (56 loc) · 1.64 KB
/
Copy pathfix_dates.js
File metadata and controls
65 lines (56 loc) · 1.64 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
55
56
57
58
59
60
61
62
63
64
var _ = require('underscore');
var read = require('read');
var Parse = require('parse').Parse;
Parse.initialize(
"dRJrkKFywmUEYJx10K96Sw848juYyFF01Zlno6Uf",
"1zVdPAD53kybPNtY2m5X7uVyEnKBE3zK5b1nWluL");
Parse.Promise.as().then(function() {
var promise = new Parse.Promise();
read({ prompt: 'Username: ' }, function(error, username) {
if (error) {
promise.reject(error);
} else {
promise.resolve(username);
}
});
return promise;
}).then(function(username) {
var promise = new Parse.Promise();
read({ prompt: 'Password: ', silent: true }, function(error, password) {
if (error) {
promise.reject(error);
} else {
promise.resolve({ username: username, password: password });
}
});
return promise;
}).then(function(userpass) {
return Parse.User.logIn(userpass.username, userpass.password);
}).then(function() {
var q = new Parse.Query("LogEntry");
q.doesNotExist("babyUuid");
//q.doesNotExist("datetime");
//q.equalTo("deleted", null);
q.ascending("updatedAt");
q.limit(1000);
return q.find();
}).then(function(entries) {
console.log("fixing " + entries.length + " entries...");
var p = Parse.Promise.as();
_.each(entries, function(obj) {
p = p.then(function() {
//obj.set("datetime",
// new Date(Date.parse(
// obj.get("time").toUTCString().replace(" GMT", " PDT"))));
//obj.set("deleted", null);
//obj.unset("deleted");
obj.set("babyUuid", "AN OLD PLACEHOLDER");
return obj.save();
});
});
return p;
}).then(function() {
console.log("Success!");
}, function(e) {
console.log("Error: " + JSON.stringify(e));
});