Mercurial Hosting > luan
comparison 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 |
comparison
equal
deleted
inserted
replaced
1391:94f48cc76de8 | 1392:002152af497a |
---|---|
1 local Lucene = require "luan:lucene/Lucene.luan" | 1 local Lucene = require "luan:lucene/Lucene.luan" |
2 local Io = require "luan:Io.luan" | 2 local Io = require "luan:Io.luan" |
3 local Hosting = require "luan:host/Hosting.luan" | |
4 local Logging = require "luan:logging/Logging.luan" | |
5 local logger = Logging.logger "Db" | |
3 | 6 |
4 | 7 |
5 local Db = {} | 8 local Db = {} |
6 | 9 |
7 local function completer(doc) | 10 local postgres_spec = Hosting.postgres_spec and Hosting.postgres_spec() |
8 return doc | 11 logger.info("postgres_spec="..postgres_spec) |
12 if postgres_spec ~= nil then | |
13 function postgres_spec.completer(doc) | |
14 return doc | |
15 end | |
9 end | 16 end |
10 | 17 |
11 function Db.new(lucene_dir) | 18 function Db.new(lucene_dir) |
12 local dir = Io.uri(lucene_dir) | 19 local dir = Io.uri(lucene_dir) |
13 local db = Lucene.index( dir, Lucene.type.english, {"subject","content"}, completer ) | 20 local db = Lucene.index( dir, Lucene.type.english, {"subject","content"}, postgres_spec ) |
14 | 21 |
15 -- this is how you index a field | 22 -- this is how you index a field |
16 -- db.indexed_fields.post_date = Lucene.type.long | 23 -- db.indexed_fields.post_date = Lucene.type.long |
17 | 24 |
18 return db | 25 return db |