Crecto
Search…
Crecto::Repo
Crecto::Repo maps the database to the database adapter, and is used to run queries on models. If connections to multiple databases is required, just create a separate Repo for each. The config block defines how the repo connects to the database.
1
module MyRepo
2
extend Crecto::Repo
3
4
config do |conf|
5
conf.adapter = Crecto::Adapters::Postgres
6
# or Crecto::Adapters::Mysql, Crecto::Adapters::SQLite3
7
conf.hostname = "localhost"
8
conf.database = "my_database"
9
end
10
end
11
12
module AnotherRepo
13
extend Crecto::Repo
14
15
config do |conf|
16
conf.adapter = Crecto::Adapters::SQLite3
17
conf.database = "./my_db.db"
18
end
19
end
Copied!
config options, all of the options from crystal-db database are implemented:
  • adapter - Specify the Crecto adapter to use: Crecto::Adapters::Postgres, Crecto::Adapters::Mysql, Crecto::Adapters::SQLite3
  • checkout_timeout
  • database - database name
  • password - database password
  • username - database username
  • uri - full uri to database, can include all config options (i.e. postgres://username:[email protected]:5432/my_db?initial_pool_size=10&retry_attemps=5)
  • hostname - database host name
  • initial_pool_size
  • max_pool_size
  • retry_attempts
  • retry_delay
Last modified 1yr ago
Copy link