dodb.cr/blah.cr
2024-05-17 19:49:09 +02:00

31 lines
519 B
Crystal

require "./src/dodb.cr"
class Car
include JSON::Serializable
property name : String
property color : String
property keywords : Array(String)
def initialize(@name, @color, @keywords)
end
end
# Database creation
db = DODB::DataBase(Car).new "db-cars"
# Adding an element to the db
db << Car.new "Corvet", "red", ["elegant", "fast"]
# Reaching all objects in the db
db.each do |car|
pp! car
end
# Reaching all objects in the db with their key.
db.each_with_index do |car,key|
pp! car, key
end
db.delete 0