Robert Clipsham avatar Robert Clipsham committed 5abed70

Begun work on SQL function support.
Breaks build for the example module.

Comments (0)

Files changed (2)

example/models/Home.d

 {
     void create()
     {
-        auto query = new SqlQuery;
-        query.createTable("blog")
-             .bind!(Post)(NotNull)
-             .field("id", PrimaryKey | AutoIncrement);
-        query.execute!(Post)();
+        with (new SqlQuery)
+        {
+            createTable("blog")
+                       .bind!(Post)(NotNull)
+                       .field("id", PrimaryKey | AutoIncrement);
+            execute!(Post)();
+        }
     }
 
-    Result!(Post) getPosts(uint limit, uint offset=0)
+    Result!(Post) getPosts(long lim, long offs=0)
     {
-        auto doc = new SqlQuery;
-        doc.select("*")
-           .from("blog")
-           .limit(limit)
-           .offset(offset);
-        return doc.execute!(Post)();
+        with (new SqlQuery)
+        {
+            select("*").from("blog")
+                       .limit(lim)
+                       .offset(offs);
+            return execute!(Post)();
+        }
     }
 
     void createPost(char[] title, char[] content)
     {
-        assert(0);
+        with (new SqlQuery)
+        {
+            insert.into("blog", "time", "title", "content")
+                  .values(now(), title, content);
+            execute!(Post)();
+        }
     }
 }

serenity/SqlQuery.d

     }
 }
 
+struct Function
+{
+    enum : uint
+    {
+        /// Give the current time in UTC
+        Now
+    }
+    alias uint Name;
+    Name name;
+    Bind[] parameters;
+}
+
 class SqlQuery
 {
     private QueryType mQt;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.