diff examples/blog/src/lib/Post.luan @ 1429:82415c9c0015

move versioning into Lucene
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 24 Nov 2019 23:07:21 -0700
parents bc40bc9aab3a
children
line wrap: on
line diff
--- a/examples/blog/src/lib/Post.luan	Sun Nov 24 21:02:38 2019 -0700
+++ b/examples/blog/src/lib/Post.luan	Sun Nov 24 23:07:21 2019 -0700
@@ -6,7 +6,7 @@
 local now = Time.now or error()
 local String = require "luan:String.luan"
 local trim = String.trim or error()
-local db = require("site:/lib/Db.luan").db or error()
+local Db = require "site:/lib/Db.luan"
 
 
 local Post = {}
@@ -33,7 +33,7 @@
 			content = this.content
 			date = this.date
 		}
-		db.save(doc)
+		Db.save(doc)
 		this.id = doc.id
 	end
 
@@ -41,12 +41,12 @@
 end
 
 function Post.get_by_id(id)
-	local doc = db.get_document("id:"..id)
+	local doc = Db.get_document("id:"..id)
 	return doc and from_doc(doc)
 end
 
 function Post.get_all()
-	local docs = db.search("type:post",1,1000,{sort="id desc"})
+	local docs = Db.search("type:post",1,1000,{sort="id desc"})
 	local posts = {}
 	for _, doc in ipairs(docs) do
 		posts[#posts+1] = from_doc(doc)
@@ -59,7 +59,7 @@
 	if #query == 0 then
 		return Post.get_all()
 	end
-	local docs = db.search(query,1,1000)
+	local docs = Db.search(query,1,1000)
 	local posts = {}
 	for _, doc in ipairs(docs) do
 		posts[#posts+1] = from_doc(doc)
@@ -68,7 +68,7 @@
 end
 
 function Post.delete_by_id(id)
-	db.delete("id:"..id)
+	Db.delete("id:"..id)
 end
 
 return Post