leafo / lapis

A web framework for Lua and OpenResty written in MoonScript
http://leafo.net/lapis/
MIT License
3.12k stars 247 forks source link

Can't set a row field to null #735

Closed eko234 closed 3 years ago

eko234 commented 3 years ago

I can't find a way to set a field back to null using the update method from a model entity, deleting the row and creating it again feels like a hack, is there a better way to do it?

CriztianiX commented 3 years ago

You can use db.NULL

db = require("lapis.db") data = { field: db.NULL, ...... }

eko234 commented 3 years ago

Thanks Criztianix, is there a way to put this in the official documentation, I think it'd be good to have an explicit example there.

CriztianiX commented 3 years ago

It is already documented https://leafo.net/lapis/reference/database.html

db.update "the_table", { name: db.NULL }

eko234 commented 3 years ago

Oh sorry, i was looking it up In the Models section, My Bad, thankyou again.