forked from Smashing/smashing
-
Notifications
You must be signed in to change notification settings - Fork 0
How To: Define a data model and store history data to database
Bruno P. Kinoshita edited this page Oct 16, 2016
·
1 revision
Dashing 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
- User Guide
- Installing Dashing
- Nginx with Passenger
- Puma
- Heroku
- Configuration
- Add Authentication
- Change default Dashboard
- Run on a different port, or in production
- Run Dashing on a sub path
- Update Font Awesome fonts from version 3 to 4
- Widgets
- Debug incoming widget data
- Additional Widgets
- Set up a graph
- Tips
- ...
- Installing Dashing
- Integrations
- Databases
- Define a data model and store history data to database
- Store and data to and display from database
- Send MySQL data to your widgets
- Other frameworks and libraries
- Django
- Monitoring
- Dashing
- CI
- Jenkins
- Issue Tracking
- JIRA
- Misc
- Update a dashboard using a spreadsheet
- Databases
- Development Instructions
- Building from source
- ...