@@ -17,19 +17,14 @@ def upsert(self, collection_name, data):
17
17
:return: http response, 201 if successful along with data posted.
18
18
19
19
**Example**::
20
- collections. upsert('user', [{"id": 1 , "name": "Juniper", "hobbies": ["Playing", "Sleeping", "Eating"]},
21
- {"id": 2 , "name": "Ruby", "interests": ["Sunbeams", "Surprise Attacks"]}])
20
+ client.collection. upsert('user', [{"id": '1' , "name": "Juniper", "hobbies": ["Playing", "Sleeping", "Eating"]},
21
+ {"id": '2' , "name": "Ruby", "interests": ["Sunbeams", "Surprise Attacks"]}])
22
22
"""
23
23
24
24
if type (data ) != list :
25
25
data = [data ]
26
26
27
- ids = [i ['id' ] for i in data ]
28
-
29
- # format data to expected json blob
30
- data_json = {}
31
- for i in range (len (ids )):
32
- data_json ['%s:%s' % (collection_name , ids [i ])] = data [i ]
27
+ data_json = {collection_name : data }
33
28
34
29
response = self .client .post ('meta' , personal = 'meta' ,
35
30
signature = self .token , data = {'data' : data_json })
@@ -44,8 +39,8 @@ def select(self, collection_name, ids):
44
39
:return: meta data as json blob
45
40
46
41
**Example**::
47
- collections. select('user', 1 )
48
- collections. select('user', [1,2,3 ])
42
+ client.collection. select('user', '1' )
43
+ client.collection. select('user', ['1','2','3' ])
49
44
"""
50
45
51
46
if type (ids ) != list :
@@ -54,6 +49,7 @@ def select(self, collection_name, ids):
54
49
foreign_ids = []
55
50
for i in range (len (ids )):
56
51
foreign_ids .append ('%s:%s' % (collection_name , ids [i ]))
52
+ foreign_ids = ',' .join (foreign_ids )
57
53
58
54
response = self .client .get ('meta' , personal = 'meta' , params = {'foreign_ids' : foreign_ids },
59
55
signature = self .token )
@@ -68,18 +64,16 @@ def delete(self, collection_name, ids):
68
64
:return: http response.
69
65
70
66
**Example**::
71
- collections.delete('user', 1 )
72
- collections.delete('user', [1,2,3 ])
67
+ client. collections.delete('user', '1' )
68
+ collections.delete('user', ['1','2','3' ])
73
69
"""
74
70
75
71
if type (ids ) != list :
76
72
ids = [ids ]
77
73
78
- foreign_ids = []
79
- for i in range (len (ids )):
80
- foreign_ids .append ('%s:%s' % (collection_name , ids [i ]))
74
+ data = {'collection_name' : collection_name , 'ids' : ids }
81
75
82
- response = self .client .delete ('meta' , personal = 'meta' , foreign_ids = foreign_ids ,
76
+ response = self .client .delete ('meta' , personal = 'meta' , data = data ,
83
77
signature = self .token )
84
78
85
79
return response
0 commit comments