-
Notifications
You must be signed in to change notification settings - Fork 0
/
query.coffee
48 lines (36 loc) · 899 Bytes
/
query.coffee
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
# ######################################
# Query operation
# http://mongoosejs.com/docs/query.html
# ######################################
# Require model
{Song} = require './models'
# #######################
# Basic find operation
# #######################
query = Song.find {}
query.exec (err, result) ->
if err
return console.log 'QUERY ERROR', err
console.log result
process.exit()
# #######################
# Fancy find operation
# #######################
# query = Song.find {}
# query.where 'artist', 'Adele'
# query.where 'genre', 'fresh'
# query.where('duration').gt(300)
# query.where('duration').lt(500)
# query.sort 'title', 1
# query.sort 'duration', 1
# query.select
# artist: 1
# title: 1
# genre: 1
# videoId: 1
# _id: 0
# query.exec (err, result) ->
# if err
# return console.log 'QUERY ERROR', err
# console.log result
# process.exit()