lib/popcorn: add limit and skip to pop_repos
authorAlexandre Terrasa <alexandre@moz-code.org>
Mon, 15 Aug 2016 23:38:42 +0000 (19:38 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Mon, 15 Aug 2016 23:38:42 +0000 (19:38 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

lib/popcorn/pop_repos.nit

index c950ea4..03cc97b 100644 (file)
@@ -149,7 +149,7 @@ interface Repository[E: Serializable]
        # Find all instances based on `query`
        #
        # Using `query` == null will retrieve all the document in the repository.
-       fun find_all(query: nullable QUERY): Array[E] is abstract
+       fun find_all(query: nullable QUERY, skip, limit: nullable Int): Array[E] is abstract
 
        # Save an `instance`
        fun save(instance: E): Bool is abstract
@@ -293,9 +293,9 @@ class MongoRepository[E: Serializable]
                return deserialize(res.to_json)
        end
 
-       redef fun find_all(query) do
+       redef fun find_all(query, skip, limit) do
                var res = new Array[E]
-               for e in collection.find_all(query or else new JsonObject) do
+               for e in collection.find_all(query or else new JsonObject, skip, limit) do
                        res.add deserialize(e.to_json).as(E)
                end
                return res