Mercurial Hosting > luan
diff examples/blog/src/lib/Db.luan @ 1220:4721c482c86b
cleaner Db example
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 21 Mar 2018 15:54:57 -0600 |
parents | examples/blog/src/lib/Db_mod.luan@bae2d0c2576c |
children | 4416b9cbebf9 |
line wrap: on
line diff
--- a/examples/blog/src/lib/Db.luan Wed Mar 21 15:36:54 2018 -0600 +++ b/examples/blog/src/lib/Db.luan Wed Mar 21 15:54:57 2018 -0600 @@ -1,1 +1,19 @@ -return require "site:/lib/Db_mod.luan".new_db() +local Lucene = require "luan:lucene/Lucene.luan" +local Io = require "luan:Io.luan" + + +local Db = {} + +function Db.new_db(lucene_dir) + local dir = Io.uri(lucene_dir).to_string() + local db = Lucene.index( dir, Lucene.type.english, {"subject","content"} ) + +-- this is how you index a field +-- db.indexed_fields.post_date = Lucene.type.long + + return db +end + +Db.db = Db.new_db("site:/private/local/lucene") + +return Db