view src/lib/Db.luan @ 38:436216d17a1b

fix edit and delete
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 12 Nov 2024 21:53:03 -0700
parents f9e6a4cc4f7d
children 9298b04607ae
line wrap: on
line source

local Luan = require "luan:Luan.luan"
local error = Luan.error
local new_error = Luan.new_error or error()
local Lucene = require "luan:lucene/Lucene.luan"
local Io = require "luan:Io.luan"
local uri = Io.uri or error()
local Http = require "luan:http/Http.luan"
local Thread = require "luan:Thread.luan"
local Time = require "luan:Time.luan"
local Logging = require "luan:logging/Logging.luan"
local logger = Logging.logger "Db"


local dir = uri("site:/private/local/lucene")

local Db = Lucene.index( dir, {
	log_dir = uri("site:/private/local/lucene_log")
	name = "lucene"
	version = 1
} )

Db.indexed_fields.user_email = Lucene.type.lowercase

Db.indexed_fields.chat_user_ids = Lucene.type.long
Db.indexed_fields.chat_updated = Lucene.type.long

Db.indexed_fields.post_chat_id = Lucene.type.long

function Db.not_in_transaction()
	logger.error(new_error("not in transaction"))
end

Db.update{
}

if Http.is_serving then
	Thread.schedule( Db.check, { delay=0, repeating_delay=Time.period{hours=1} } )
end

return Db