-
Notifications
You must be signed in to change notification settings - Fork 1
/
models.py
34 lines (24 loc) · 807 Bytes
/
models.py
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
import pymongo
client = pymongo.MongoClient()
db = client['radar']
class MongoDAO(object):
def __init__(self, collname):
self.coll = db[collname]
@property
def collection(self):
return self.coll
def find(self, *args, **kwargs):
print "%s, %s" % (args,kwargs)
return self.coll.find(*args, **kwargs)
def find_one(self, *args, **kwargs):
return self.coll.find_one(*args, **kwargs)
def insert_one(self, *args, **kwargs):
return self.coll.insert_one(*args, **kwargs)
def update_one(self, *args, **kwargs):
return self.coll.update_one(*args, **kwargs)
def distinct(self, *args, **kwargs):
return self.coll.distinct(*args, **kwargs)
Products = MongoDAO('product')
ProductTypes = MongoDAO('product_type')
Transformations = MongoDAO('transformation')
Processes = MongoDAO('plugin')