Helma Logo
main list history

Version 3 by hannes on 22. September 2009, 09:18

1Helma 1.7 introduces a much requested feature to create HopObject collections programmatically and on the fly, without having to define them in the prototype's *type[type.properties|docs/typeproperties][documentation/type.properties documentation* documentation] file.
20    var c = Page.getCollection({
21        group: "author",
22        "group.order": "author",
23        "group.prototype": "AuthorGroup"
24    });

Version 2 by hannes on 01. April 2009, 17:54

26Since I thought it would be handy, I also implemented "limit" and "offset" collection properties to implement easy pagination on dbs that support it (Postgresql and Mysql AFAIK): pagination:
28http://www.sql.org/sql-database/postgresql/manual/queries-limit.html
29
36Note that "limit" is just an alias for "maxSize" introduced to be more consistent with the underlying SQL syntax. This feature is currently not supported on Oracle. If somebody can provide the SQL syntax needed to make this work on Oracle plus some testing support, I'll happily add this.
37
38This feature is currently implemented and known to work on MySQL, Postgresql, and Oracle.

Version 1 by hannes on 31. März 2009, 14:45

1Helma 1.7 introduces a much requested feature to create HopObject collections programmatically and on the fly, without having to define them in the prototype's *type.properties|docs/type.properties documentation* file.
2
3HopObject constructors now have a new static getCollection() method that takes a single JS object argument. The argument contains the collection properties as you would normally define them in the _children section of the type.properties file, e.g.:
4
5    var c = Page.getCollection({
6        order: "name",
7        filter: "id > 10",
8    };
9
10You can also specify the type of contained objects using the "collection" property, so the following collection is equivalent to the one defined above:
11
12    var c = HopObject.getCollection({
13        collection: "Page",
14        order: "name",
15        filter: "id > 10",
16    };
17
18Note that for "nested" properties such as group.order or local.1 you have to use quoted "flat" properties, not nested objects:
19
20  var c = Page.getCollection({
21      group: "author",
22      "group.order": "author",
23      "group.prototype": "AuthorGroup"
24  });
25
26Since I thought it would be handy, I also implemented "limit" and "offset" collection properties to implement easy pagination on dbs that support it (Postgresql and Mysql AFAIK):
27
28http://www.sql.org/sql-database/postgresql/manual/queries-limit.html
29
30So to fetch pages 11-20, you would do something like this:
31
32    var q = Page.getCollection({
33        limit: 10,
34        offset: 10
35    });
36
37Note that "limit" is just an alias for "maxSize" introduced to be more consistent with the underlying SQL syntax. This feature is currently not supported on Oracle. If somebody can provide the SQL syntax needed to make this work on Oracle plus some testing support, I'll happily add this.