-
Notifications
You must be signed in to change notification settings - Fork 323
How To: Define a data model and store history data to database
Bruno P. Kinoshita edited this page Jul 6, 2022
·
3 revisions
Smashing is build based on Sinatra, if you are already familiar with Sinatra, then I am sure this won't be a problem.
This guide aims for the people who are not so familiar with Sinatra and want a quick hint.
gem 'dm-sqlite-adapter'
gem 'data_mapper'
require "data_mapper"
DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/database.db")
class YourDataModel
include DataMapper::Resource
property :id, Serial
property :createdAt, DateTime
property :serviceName, String
property :available, Boolean, :default => true
end
# Perform basic sanity checks and initialize all relationships
# Call this when you've defined all your models
DataMapper.finalize
# automatically create the post table
YourDataModel.auto_upgrade!
YourDataModel.new({:createdAt => DateTime.now, :serviceName => 'service1', :available => succeed}).save()
puts "YourDataModel.all().count #{YourDataModel.all().count}"
- Home
- Dashing Workshop
- Installation
- Widgets
- Configuration
- Security
- Troubleshooting
- Deploying dashboards
- How Tos
- How to: post data to your dashboard and widgets
- How to: Define a data model and store history data to database
- How to: Prevent a job from overlapping with itself
- How to: Send HTML data to your widgets
- How to: Send mysql data to your widgets
- How to: Setup a Graph
- How to: Store data to and display from database
- How to: Update a Dashboard using a spreadsheet
- How to: update dashboard in Django
- How to: Update font awesome fonts from version 3 to 4
- How to: Use New Relic with Dashing
- How to: precompile assets
- Development