Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom LoopBack Model with Created/Modified

It looks like the built in LoopBack models are baked with "create/modified" date fields. Is there an easy way to add this to "generated" models? I've been looking through the docs but can't find anything in the model docs- http://docs.strongloop.com/display/public/LB/Defining+models

Any suggestions?

like image 381
bstar Avatar asked Feb 18 '15 21:02

bstar


People also ask

What is LoopBack model?

A LoopBack model is a JavaScript object with both Node and REST APIs that represents data in backend systems such as databases. Models are connected to backend systems via data sources. You use the model APIs to interact with the data source to which it is attached.


2 Answers

I'm pretty sure this is what you are looking for: https://github.com/clarkbw/loopback-ds-timestamp-mixin

like image 104
Kenneth Lynne Avatar answered Oct 03 '22 18:10

Kenneth Lynne


There is no built-in way ATM. I suggest using an operation hook mixed with new Date(). See http://docs.strongloop.com/display/public/LB/Operation+hooks#Operationhooks-beforesave.

like image 21
superkhau Avatar answered Oct 02 '22 18:10

superkhau