Mercurial Hosting > luan
annotate examples/blog/src/lib/Db.luan @ 2023:544ccce564f6
minor
| author | Franklin Schmidt <fschmidt@gmail.com> | 
|---|---|
| date | Mon, 20 Oct 2025 17:34:14 -0600 | 
| parents | 9e0cf623ecc5 | 
| children | 
| rev | line source | 
|---|---|
| 1396 
a5f61890ad84
add check_postgres_password
 Franklin Schmidt <fschmidt@gmail.com> parents: 
1395diff
changeset | 1 local Luan = require "luan:Luan.luan" | 
| 
a5f61890ad84
add check_postgres_password
 Franklin Schmidt <fschmidt@gmail.com> parents: 
1395diff
changeset | 2 local error = Luan.error | 
| 
a5f61890ad84
add check_postgres_password
 Franklin Schmidt <fschmidt@gmail.com> parents: 
1395diff
changeset | 3 local stringify = Luan.stringify or error() | 
| 693 
ca169567ce07
module URIs must now include ".luan"
 Franklin Schmidt <fschmidt@gmail.com> parents: 
599diff
changeset | 4 local Lucene = require "luan:lucene/Lucene.luan" | 
| 
ca169567ce07
module URIs must now include ".luan"
 Franklin Schmidt <fschmidt@gmail.com> parents: 
599diff
changeset | 5 local Io = require "luan:Io.luan" | 
| 1672 | 6 local uri = Io.uri or error() | 
| 1399 | 7 local Time = require "luan:Time.luan" | 
| 8 local Thread = require "luan:Thread.luan" | |
| 1672 | 9 local Hosted = require "luan:host/Hosted.luan" | 
| 1392 | 10 local Logging = require "luan:logging/Logging.luan" | 
| 11 local logger = Logging.logger "Db" | |
| 596 | 12 | 
| 13 | |
| 1672 | 14 local dir = uri("site:/private/local/lucene") | 
| 1429 
82415c9c0015
move versioning into Lucene
 Franklin Schmidt <fschmidt@gmail.com> parents: 
1418diff
changeset | 15 local Db = Lucene.index( dir, { | 
| 
82415c9c0015
move versioning into Lucene
 Franklin Schmidt <fschmidt@gmail.com> parents: 
1418diff
changeset | 16 default_type = Lucene.type.english | 
| 
82415c9c0015
move versioning into Lucene
 Franklin Schmidt <fschmidt@gmail.com> parents: 
1418diff
changeset | 17 default_fields = {"subject","content"} | 
| 1672 | 18 log_dir = uri("site:/private/local/lucene_log") | 
| 1429 
82415c9c0015
move versioning into Lucene
 Franklin Schmidt <fschmidt@gmail.com> parents: 
1418diff
changeset | 19 } ) | 
| 
82415c9c0015
move versioning into Lucene
 Franklin Schmidt <fschmidt@gmail.com> parents: 
1418diff
changeset | 20 | 
| 596 | 21 -- this is how you index a field | 
| 22 -- db.indexed_fields.post_date = Lucene.type.long | |
| 23 | |
| 1672 | 24 Db.restore_from_log() | 
| 1429 
82415c9c0015
move versioning into Lucene
 Franklin Schmidt <fschmidt@gmail.com> parents: 
1418diff
changeset | 25 Db.update{ | 
| 
82415c9c0015
move versioning into Lucene
 Franklin Schmidt <fschmidt@gmail.com> parents: 
1418diff
changeset | 26 [1] = function() | 
| 
82415c9c0015
move versioning into Lucene
 Franklin Schmidt <fschmidt@gmail.com> parents: 
1418diff
changeset | 27 logger.info "update" | 
| 
82415c9c0015
move versioning into Lucene
 Franklin Schmidt <fschmidt@gmail.com> parents: 
1418diff
changeset | 28 end | 
| 
82415c9c0015
move versioning into Lucene
 Franklin Schmidt <fschmidt@gmail.com> parents: 
1418diff
changeset | 29 } | 
| 2011 | 30 Thread.schedule( Db.check, { delay=0, repeating_delay=Time.period{hours=1} } ) | 
| 1399 | 31 | 
| 1220 | 32 return Db | 
