vania-dart / framework

Fast, simple, and powerful backend framework for Dart built with ❤️
https://vdart.dev
MIT License
155 stars 12 forks source link

[BUG] - Returning Insert To Database Is Nothing #71

Closed alirezat66 closed 2 weeks ago

alirezat66 commented 1 month ago

Describe the bug When you insert a data on database, we got nothing `final result = await TaskList().query().insert({ 'title': request.input('title'), 'user_id': Auth().id(), 'created_at': DateTime.now(), 'updated_at': DateTime.now(), 'background_color': request.input('background_color', null), });

return Response.json(
    {"message": "Task list created successfully", "data": result});`

then you see:

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem. { "message": "Task list created successfully", "data": [] } Environment (please complete the following information):

javad-zobeidi commented 1 month ago

Actually, this is not a bug The data is stored correctly in the database. To get the data you need to use insertGetId, again get the data by the ID with first

javad-zobeidi commented 2 weeks ago

Add to version 0.3.2 now you can use the create method

https://vdart.dev/docs/eloquent-orm/eloquent/#create-and-return-inserted-data