-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
89 lines (62 loc) · 2.45 KB
/
index.html
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Mongogx</title>
<script type="application/javascript" src="collection.mongogx.js"></script>
<script type="application/javascript" src="database.mongogx.js"></script>
<script type="application/javascript" src="core.mongogx.js"></script>
<script type="application/javascript">
let mongogx = new OGX.Mongogx();
mongogx.createDatabase('my_project');
mongogx.setDatabase('my_project');
mongogx.createCollection('users');
mongogx.setCollection('users');
mongogx.insert({first_name:'Eric', age:42, sex:'male', location:{state:'ON', city:'Toronto'}, favorites:{meals:[{name:'pizza'}, {name:'pasta'}]}});
mongogx.insert({first_name:'Tania', age:38, sex:'female', location:{state:'ON', city:'Toronto'}});
mongogx.insert({first_name:'Julien', age:45, sex:'male', location:{state:null, city:'Stockholm'}});
mongogx.insert({first_name:'George', age:55, sex:'male', location:{state:'QC', city:'Montreal'}, arts:{martial:['kickboxing', 'wresting']}});
/*
console.log(mongogx.find({'location.state':'ON'}));
console.log(mongogx.find({age:42}));
console.log(mongogx.find({age:{$gt:20}}));
console.log(mongogx.find({age:{gt:20}, sex:'male', 'location.city':'Toronto'}));
console.log(mongogx.find({'favorites.meals.name':'pizza'}));
console.log(mongogx.find({'favorites.meals.1.name':'pasta'}));
*/
console.log(mongogx.find({'arts.martial':{'$in':'kickboxing'}}));
/*
batchInsert();
let start = new Date().getTime();
let users = mongogx.find({'city':'Paris', 'age':{'$gt':20}}, 10);
let end = new Date().getTime();
console.log('FIND TIME', (end-start), 'ms', users);
function batchInsert(){
let start, end;
start = new Date().getTime();
let user;
let names = ['Eric', 'Tania', 'Frank', 'Julien', 'Jennifer', 'Thomas', 'Jessica', 'Joe', 'Stacy', 'Brad'];
var cities = ['Toronto', 'New York', 'Las Vegas', 'Paris', 'London', 'Madrid', 'Los Angeles'];
for(let i = 0; i < 10000; i++){
user = {first_name:names[Math.floor(Math.random()*names.length)], age:10+Math.round(Math.random()*50), city:cities[Math.floor(Math.random()*cities.length)]};
mongogx.insert(user);
}
end = new Date().getTime();
console.log('INSERT TIME', (end-start), 'ms');
}
*/
/*
states.$.cities.$.area_codes.$.code = 416;
states:{
ontario:{
cities:[
{name:toronto, area_codes:[{code:416, code:905}]}, {name:markham}
]
}
}
*/
</script>
</head>
<body>
</body>
</html>