If a db.schedule table exists with db.schedule.todays_date set to today's date. For example, if I, as a user, wake up today to enter my daily tasks for the current day, it gives a crud.create() form to insert a new db.schedule record. If I log in at lunch to add/modify activities further, it gives a crud.update() form to the same db.schedule record for today's date.
On Jan 20, 9:37 pm, Massimo Di Pierro <[email protected]> wrote: > what is the condition to decide whether is exists or not? > > On Jan 20, 7:24 pm, dominatus <[email protected]> wrote: > > > > > > > > > I have a table in one of my models that I am trying to either create > > or update based on the current date when the user logs in. I noticed > > there is no explainable way to check if a current record exists in a > > model from within a controller function. Do we have to use: > > > crud.create(db.schedule) or crud.update(db.schedule, > > db.schedule((auth.user.id == db.schedule.user)) & > > (db.schedule.todays_date == datetime.date.time())).select(id) > > > In Django there is simply a get_or_create() function to perform this > > task. Just wondering if this is the right way of going about it. > > Thanks.

