File tree Expand file tree Collapse file tree 1 file changed +61
-10
lines changed
Expand file tree Collapse file tree 1 file changed +61
-10
lines changed Original file line number Diff line number Diff line change @@ -297,32 +297,83 @@ Type
297297
298298-------------------------------------------------------------------------------
299299
300- *********
301- Timestamp
302- *********
300+ ****
301+ Date
302+ ****
303303
304- Used for storing datetimes .
304+ Used for storing dates .
305305
306306Example
307307=======
308308
309309.. code-block :: python
310310
311311 class Concert (Table ):
312- starts = Timestamp ()
312+ starts = Date ()
313313
314- It's common to want a default for a timestamp column. Having functions as
315- defaults can cause issues for migrations, so the recommended way to have
316- a default of `now ` is as follows:
314+ Type
315+ ====
316+
317+ ``Date `` uses the ``date `` type for values.
317318
318319.. code-block :: python
319320
320- from piccolo.columsn.defaults.timestamp import TimestampNow
321+ import datetime
321322
323+ # Create
324+ >> > Concert(starts = datetime.date(year = 2020 , month = 1 , day = 1 )).save().run_sync()
325+
326+ # Query
327+ >> > Concert.select(Concert.starts).run_sync()
328+ {' starts' : datetime.date(2020 , 1 , 1 )}
329+
330+ -------------------------------------------------------------------------------
331+
332+ ****
333+ Time
334+ ****
335+
336+ Used for storing times.
337+
338+ Example
339+ =======
340+
341+ .. code-block :: python
322342
323343 class Concert (Table ):
324- starts = Timestamp(default = TimestampNow())
344+ starts = Time()
345+
346+ Type
347+ ====
348+
349+ ``Time `` uses the ``time `` type for values.
350+
351+ .. code-block :: python
352+
353+ import datetime
354+
355+ # Create
356+ >> > Concert(starts = datetime.time(hour = 20 , minute = 0 , second = 0 )).save().run_sync()
357+
358+ # Query
359+ >> > Concert.select(Concert.starts).run_sync()
360+ {' starts' : datetime.time(20 , 0 , 0 )}
361+
362+ -------------------------------------------------------------------------------
325363
364+ *********
365+ Timestamp
366+ *********
367+
368+ Used for storing datetimes.
369+
370+ Example
371+ =======
372+
373+ .. code-block :: python
374+
375+ class Concert (Table ):
376+ starts = Timestamp()
326377
327378 Type
328379====
You can’t perform that action at this time.
0 commit comments