Topaz Crystal Topaz Versions Save

A simple and useful db wrapper for Crystal-lang

v0.2.7

7 years ago

Support default value(https://github.com/topaz-crystal/topaz/pull/9) :tada: See discussion here

Sample for this feature is here

v0.2.6

7 years ago

This release includes following topics.

All pull requests are by @Zhomart:tada: Thanks a lot!

Very welcome to up PR from you:smile:

v0.2.5

7 years ago

This release includes following topics.

v0.2.4

7 years ago

I'm happy to announce to release new tool that build a kemal project with topaz. :tada: You can simply start with it like

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/topaz-crystal/topaz/master/tools/install.rb)"

This release includes bug fixes and refactoring.

v0.2.3

7 years ago

Updates

  • Support table migration!:tada: Doc
  • Bug fixes (Especially for PostgreSQL)

v0.2.2

7 years ago

Suppoort Crystal version 0.20.3 :tada: Nullable column is accepted.(See below sample) Support to_json and from_json(#json is deprecated) Topaz::Log.show_query is now Topaz::Db.show_query

class NullableModel < Topaz::Model
  columns(
    name: String,
    nullable: {type: String, nullable: true},
    not_nullable: {type: String, nullable: false},
  )
end

NullableModel.create("sample", nil, "not nullable")

v0.2.1

7 years ago
  • Support transaction! :tada: (Thanks @bcardiff)
  • join is deprecated

See sample/transaction.cr as a sample code

[Sample code]
Topaz::Db.shared.transaction do |tx|
    Sample.in(tx).create("sample0")
    Sample.in(tx).create("sample1")
    ...
    t0 = Sample.in(tx).find(1)
    t0.in(tx).update(name: "sample0 updated")
end

v0.2.0

7 years ago
  • Support PostgreSQL:tada: (Thanks @will and @asterite)
  • Simplify core macros(columns, has_many, belongs_to)
  • primary is deprecated (You have to control it on code level)

Example:

Previous

class Parent < Topaz::Model
  columns(
    {name: name, type: String}
  )
  has_many(
    {model: Child, as: childlen, key: p_id}
  )
end

Now

class Parent < Topaz::Model
  columns(
    name: String
  )
  has_many(
    childlen: {model: Child, key: p_id}
  )
end

v0.1.0

7 years ago

Version 0.1.0 Now Topaz is enough stable so that increment minor version from 0 to 1 :tada: Reduced Database overhead by keeping opening connection with it. Thanks @asterite !

Any issues or PRs are welcome :)

v0.0.5

7 years ago

Converting models to jsons is a necessary feature for who develops api server. Now your api easily generate and return jsons of models with Topaz.

For example, when we have

JsonParent(name)
 - JsonChild(age, p_id)
   - JsonToy(name, price, c_id)
    - JsonPart(t_id)
 - JsonPet(p_id)

Then we can write like

p = JsonParent.select.first

puts p.json
puts p.json({include: :childlen, except: :id})
puts p.json({include: {childlen: {except: [:id, :p_id]}, pets: nil} })
puts p.json({include: {childlen: {include: {toies: {include: :parts, only: :price} } }, pets: nil} })

We got

{"id": 1, "name": "John"}

{"name": "John", "childlen": [{"id": 1, "age": 12, "p_id": 1}, {"id": 2, "age": 15, "p_id": 1}, {"id": 3, "age": 23, "p_id": 1}]}

{"id": 1, "name": "John", "childlen": [{"age": 12}, {"age": 15}, {"age": 23}], "pets": [{"id": 1, "p_id": 1}, {"id": 2, "p_id": 1}, {"id": 3, "p_id": 1}, {"id": 4, "p_id": 1}]}

{"id": 1, "name": "John", "childlen": [{"id": 1, "age": 12, "p_id": 1, "toies": [{"price": 10, "parts": [{"id": 1, "t_id": 1}]}, {"price": 12, "parts": []}]}, {"id": 2, "age": 15, "p_id": 1, "toies": [{"price": 15, "parts": [{"id": 2, "t_id": 3}, {"id": 3, "t_id": 3}, {"id": 4, "t_id": 3}]}]}, {"id": 3, "age": 23, "p_id": 1, "toies": []}], "pets": [{"id": 1, "p_id": 1}, {"id": 2, "p_id": 1}, {"id": 3, "p_id": 1}, {"id": 4, "p_id": 1}]}