anykeyh / clear

Advanced ORM between postgreSQL and Crystal
https://github.com/anykeyh/clear
MIT License
272 stars 34 forks source link

[Question] Deleting a record #5

Closed prutya closed 6 years ago

prutya commented 6 years ago

Hi, Looks like there is only one way to delete a record:

def destroy(env)
  id = env.params.url["id"].to_i
  group = TodoGroup.find!(id)
  delete_query = Clear::SQL::DeleteQuery.new.from("todo_groups").where({ id: id }).to_sql
  Clear::SQL.execute(delete_query)
end

Am I right?

anykeyh commented 6 years ago

Hello,

Indeed, it looks like I forgot to implement model deletion 😅 .

I'm going to fix this today, you will be able to call destroy on the model tomorrow.

anykeyh commented 6 years ago

It's now done.

Note than the method is delete like in SQL and not destroy like in ActiveRecord.

prutya commented 6 years ago

Great, thank you ☺️