-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
39 lines (31 loc) · 916 Bytes
/
app.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
define(function(require){
var Mongo = require('backbone-mongo');
var data = require('components/data');
var people = new Mongo();
people.insert(data);
people.find({ name: 'Alex' });
people.insert({ name: 'Alex', score: 11 });
people.insert({ name: 'Claire', score: 11 });
var query = $('#query');
var runQuery = function(e) {
if (e.which == 13){
e.preventDefault();
var command = $(e.target).val();
var result, commandResult;
try {
commandResult = eval(command);
} catch (err){
$('.results').html(err.toString());
} finally {
try {
result = JSON.stringify(commandResult, 2, 2);
} catch (err){
result = commandResult;
}
$('.results').html(result);
}
}
};
query.on('keyup', runQuery);
return people;
});