Mercurial Hosting > luan
diff examples/blog/src/lib/Db.luan @ 1392:002152af497a
hosted postgres
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 06 Sep 2019 00:19:47 -0600 |
parents | 94f48cc76de8 |
children | cc0dbca576dc |
line wrap: on
line diff
--- a/examples/blog/src/lib/Db.luan Thu Sep 05 01:29:57 2019 -0600 +++ b/examples/blog/src/lib/Db.luan Fri Sep 06 00:19:47 2019 -0600 @@ -1,16 +1,23 @@ local Lucene = require "luan:lucene/Lucene.luan" local Io = require "luan:Io.luan" +local Hosting = require "luan:host/Hosting.luan" +local Logging = require "luan:logging/Logging.luan" +local logger = Logging.logger "Db" local Db = {} -local function completer(doc) - return doc +local postgres_spec = Hosting.postgres_spec and Hosting.postgres_spec() +logger.info("postgres_spec="..postgres_spec) +if postgres_spec ~= nil then + function postgres_spec.completer(doc) + return doc + end end function Db.new(lucene_dir) local dir = Io.uri(lucene_dir) - local db = Lucene.index( dir, Lucene.type.english, {"subject","content"}, completer ) + local db = Lucene.index( dir, Lucene.type.english, {"subject","content"}, postgres_spec ) -- this is how you index a field -- db.indexed_fields.post_date = Lucene.type.long