[NJS] Database handling #1
With Sinatra, I was using DataMapper as ORM (Object Relational Mapper) for Postgres, and I got a bit spoiled, because it makes things really easy. You first have to define your data mapping:
class Post
include DataMapper::Resource
# Set the number of characters for these types of fields, if the DB supports it
DataMapper::Property::String.length(255)
DataMapper::Property::Text.length(999999)
property :id, Serial
property :title, Text
property :body, Text
property :datetime, String
property :modified, String
property :link, String
endAnd using it is really straightforward: