diff examples/blog/src/lib/Post.luan @ 1088:bae2d0c2576c

change module naming convention
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 26 Dec 2016 22:29:36 -0700
parents c38f6619feb9
children 1f9d34a6f308
line wrap: on
line diff
--- a/examples/blog/src/lib/Post.luan	Mon Dec 19 01:38:21 2016 -0700
+++ b/examples/blog/src/lib/Post.luan	Mon Dec 26 22:29:36 2016 -0700
@@ -9,10 +9,10 @@
 local Db = require "site:/lib/Db.luan"
 
 
-local M = {}
+local Post = {}
 
 local function from_doc(doc)
-	return M.new {
+	return Post.new {
 		id = doc.id
 		subject = doc.subject
 		content = doc.content
@@ -20,7 +20,7 @@
 	}
 end
 
-function M.new(this)
+function Post.new(this)
 	assert_string(this.subject)
 	assert_string(this.content)
 	this.date = this.date or now()
@@ -40,12 +40,12 @@
 	return this
 end
 
-function M.get_by_id(id)
+function Post.get_by_id(id)
 	local doc = Db.get_document("id:"..id)
 	return doc and from_doc(doc)
 end
 
-function M.get_all()
+function Post.get_all()
 	local docs = Db.search("type:post",1,1000,"id desc")
 	local posts = {}
 	for _, doc in ipairs(docs) do
@@ -54,10 +54,10 @@
 	return posts
 end
 
-function M.search(query)
+function Post.search(query)
 	query = trim(query)
 	if #query == 0 then
-		return M.get_all()
+		return Post.get_all()
 	end
 	local docs = Db.search(query,1,1000)
 	local posts = {}
@@ -67,4 +67,4 @@
 	return posts
 end
 
-return M
+return Post