-
Notifications
You must be signed in to change notification settings - Fork 0
/
query.js
64 lines (47 loc) · 1.01 KB
/
query.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* Created by k33g_org on 23/05/14.
*/
var nohm = require('nohm').Nohm
, redis = require('redis').createClient();
redis.on("error", function (err) {
console.log("Error " + err);
});
redis.on("ready", function (err) {
nohm.setClient(redis);
console.log("Connected");
var UserModel = nohm.model('User', {
properties: {
id: {
type: 'string',
unique: true
},
name: {
type: 'string',
index: true
},
email: {
type: 'string',
index: true
},
country: {
type: 'string',
index: true
}
}
});
//England
UserModel.find({
country: 'England'
}, function (err, ids) {
console.log("English people", ids.length)
nohm.factory('User', ids[345], function (err) {
if (err === 'not found') {
console.log(err);
} else if (err) {
console.log(err); // database or unknown error
} else {
console.log(this.allProperties());
}
});
});
});