comparison src/lib/Post.luan @ 24:af41be2dcdec

add edit_post
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 05 Nov 2024 19:45:08 -0700
parents c54c806fcc6e
children 9298b04607ae
comparison
equal deleted inserted replaced
23:c54c806fcc6e 24:af41be2dcdec
36 local doc = to_doc(post) 36 local doc = to_doc(post)
37 Db.save(doc) 37 Db.save(doc)
38 post.id = doc.id 38 post.id = doc.id
39 end 39 end
40 40
41 function post.reload()
42 return Post.get_by_id(post.id) or error(post.id)
43 end
44
41 function post.delete() 45 function post.delete()
42 run_in_transaction( function() 46 run_in_transaction( function()
43 local id = post.id 47 local id = post.id
44 Db.delete("id:"..id) 48 Db.delete("id:"..id)
45 end ) 49 end )