view examples/blog/src/lib/Db.luan @ 1396:a5f61890ad84

add check_postgres_password
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 10 Sep 2019 13:41:22 -0600
parents 9dfff82dfc59
children 0dc9837c16be
line wrap: on
line source

local Luan = require "luan:Luan.luan"
local error = Luan.error
local stringify = Luan.stringify or error()
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 postgres_spec = Hosting.postgres_spec and Hosting.postgres_spec()
--logger.info(stringify(postgres_spec))

local function completer(doc)
	return doc
end

function Db.new(lucene_dir)
	local dir = Io.uri(lucene_dir)
	local db = Lucene.index( dir, {
		default_type = Lucene.type.english
		default_fields = {"subject","content"}
		completer = completer
		postgres_spec = postgres_spec
	} )
	
--	this is how you index a field
--	db.indexed_fields.post_date = Lucene.type.long

	return db
end

Db.db = Db.new("site:/private/local/lucene")

--Db.db.restore_from_postgres()
Db.db.check()
return Db