[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Sailor - Representing datetime values in the model sintax
- From: luciano de souza <luchyanus@...>
- Date: Sat, 28 Feb 2015 11:15:52 -0300
Hello all,
I got an error about a Sailor model.
Let's see the database structure:
create table entries
(
id integer primary key not null,
created datetime not null,
content text not null
);
Now, let me show how I have represented it in the Sailor model:
-- /models/entry.lua
local val = require('valua')
local M = {}
M.attributes = {
{id = 'safe'},
{created = val.new().datetime()},
{content = val.new().text()}
}
M.db = {
key = 'id',
table = 'entries'
}
return M
I did:
$ lua entry.lua
I got:
lua: /usr/local/share/lua/5.1/valua.lua:45: attempt to index local
'self' (a nil value)
stack traceback:
/usr/local/share/lua/5.1/valua.lua:45: in function 'new'
entry.lua:6: in main chunk
[C]: ?
Accessing http://localhost:8080/entry/create, the error points to the
same line 6, in other words:
created = val.new().datetime()
The answer is that I don't know how to represent datetime values in
the Sailor model sintax.
Before an integer, I would do:
age = val.new().integer()
Before a text, I would do:
name = val.new().text()
but what to do in the case of datetime values?
In Sqlite3, I have the option to define created as a datetime or a
timestamp, but, the doubt is the same in the both cases.
Best regards,
--
Luciano de Souza