Class: Cloudflare::D1::Model
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Cloudflare::D1::Model
- Defined in:
- lib/cloudflare/d1/model.rb
Overview
Base class for D1-backed ActiveRecord models
Example usage:
class User < Cloudflare::D1::Model
# Automatically uses D1 database named "users" (inferred from table_name)
end
# Configure in database.yml:
# production:
# adapter: cloudflare_d1
# account_id: <%= ENV['CLOUDFLARE_ACCOUNT_ID'] %>
# api_token: <%= ENV['CLOUDFLARE_API_TOKEN'] %>
# database_id: users_db_uuid
Class Method Summary collapse
-
.cloudflare_account_id ⇒ String
Returns the Cloudflare account ID from the connection configuration.
-
.d1_database_id ⇒ String
Returns the D1 database ID from the connection configuration.
-
.d1_database_name ⇒ String
Returns the D1 database name inferred from the table name.
Class Method Details
.cloudflare_account_id ⇒ String
Returns the Cloudflare account ID from the connection configuration
40 41 42 |
# File 'lib/cloudflare/d1/model.rb', line 40 def cloudflare_account_id connection_db_config.configuration_hash[:account_id] end |
.d1_database_id ⇒ String
Returns the D1 database ID from the connection configuration
34 35 36 |
# File 'lib/cloudflare/d1/model.rb', line 34 def d1_database_id connection_db_config.configuration_hash[:database_id] end |
.d1_database_name ⇒ String
Returns the D1 database name inferred from the table name
28 29 30 |
# File 'lib/cloudflare/d1/model.rb', line 28 def d1_database_name table_name end |