@@ -44,11 +44,11 @@ Retrieving entities from dandelion is easy, just instantiate a Datagem and itera
4444
4545### Select fields
4646
47- If you want to reduce the network load, you can retrieve only the fields you will actually use with ` values ` :
47+ If you want to reduce the network load, you can retrieve only the fields you will actually use with ` select ` :
4848
4949 >>> from dandelionimport Datagem
5050 >>> d = Datagem('datagem-slug')
51- >>> for obj in d.objects.values ('acheneID')[:10]:
51+ >>> for obj in d.objects.select ('acheneID')[:10]:
5252 ... print obj
5353 ...
5454 {u'acheneID': u'http://dandelion.eu/resource/158dce3ea58cebda9a14a911cd7574f204f9de72'}
@@ -64,7 +64,7 @@ If you want to reduce the network load, you can retrieve only the fields you wil
6464
6565It is also possible to rename fields if you need to:
6666
67- >>> for obj in d.objects.values ('acheneID', 'municipality.name AS "name"')[:10]:
67+ >>> for obj in d.objects.select ('acheneID', 'municipality.name AS "name"')[:10]:
6868 ... print obj
6969 ...
7070 {u'acheneID': u'http://dandelion.eu/resource/158dce3ea58cebda9a14a911cd7574f204f9de72', u'name': u'Dresano'}
@@ -81,9 +81,9 @@ It is also possible to rename fields if you need to:
8181
8282### Filter elements
8383
84- You can powerfully filter the result set with the ` filter ` method:
84+ You can powerfully filter the result set with the ` where ` method:
8585
86- >>> for obj in d.objects.filter (level=60)[:10]:
86+ >>> for obj in d.objects.where (level=60)[:10]:
8787 ... print obj['acheneID'], obj['level']
8888 ...
8989 http://dandelion.eu/resource/a7d36ba742d54e8a97f187cf3d33a3beb6043057 60
@@ -99,7 +99,7 @@ You can powerfully filter the result set with the `filter` method:
9999
100100More complex filters can be achieved with the ` __ ` (dunder) operator:
101101
102- >>> for obj in d.objects.filter (level__lt=30)[:10]:
102+ >>> for obj in d.objects.where (level__lt=30)[:10]:
103103 ... print obj['acheneID'], obj['country']['name']
104104 ...
105105 http://dandelion.eu/resource/3058697c2d534d13b48f20e1d530dea1794d58b2 FRANCE
@@ -120,3 +120,27 @@ Available comparators are:
120120 * gte (greater-than-equals, ` >= ` )
121121 * gt (greater-than, ` > ` )
122122 * not (not, ` <> ` )
123+
124+
125+ ### Sort elements
126+
127+ Sorting is easy as everything else, with the ` sort ` method:
128+
129+ >>> for obj in d.objects.select('acheneID').order('acheneID')[:5]:
130+ ... print obj['acheneID']
131+ ...
132+ http://dandelion.eu/resource/00017329d07750b26ffc0efb08c3a862b1898a0d
133+ http://dandelion.eu/resource/00026440c06c9774bfbb08e770167c9ad09124a1
134+ http://dandelion.eu/resource/0002abf01d8bdfcb13e5d01625c806ad2b3a06f3
135+ http://dandelion.eu/resource/0002e35e46df47106976c746606cc7188d1a039e
136+ http://dandelion.eu/resource/0003080a25b86105ba3f538b5d857b6a31b6646d
137+
138+
139+ >>> for obj in d.objects.select('acheneID').order('acheneID DESC')[:5]:
140+ ... print obj['acheneID']
141+ ...
142+ http://dandelion.eu/resource/ffff40dff5241feb1ecc394e79bfd820d54d43d8
143+ http://dandelion.eu/resource/ffff31c2ec23ff3a18da4804cdbd869c11120ca7
144+ http://dandelion.eu/resource/fffb71883dbeaf8511f58a6d5260c5cb1c52be74
145+ http://dandelion.eu/resource/fffb636f2df4a5be30e3d56da3df2dc388a534a5
146+ http://dandelion.eu/resource/fffacd9ff1bdaca8107642a1048be2bef5796a53
0 commit comments