structure icon indicating copy to clipboard operation
structure copied to clipboard

Creating timestamp plugin

Open wenderjean opened this issue 8 years ago • 3 comments

My proposal is to create a new plugin to add timestamp behavior to a structure, what I mean?

I am current in a project that adds a document to a NoSQL database, I want to have a created_at and updated_at to that document, what if I could create a new structure and invoke something like mystructure.updateTimestamps() to set created and updated times to me.

wenderjean avatar Jul 24 '17 18:07 wenderjean

I think it's a good idea. We could create a plugin system that is passed as the second parameter os attributes, like:

attributes({
  name: String
}, {
  plugins: [timestampsPlugin]
})(class User { });

Question: should the plugin add those fields automatically to the model or will they just update the values?

talyssonoc avatar Jul 26 '17 06:07 talyssonoc

I think It should add fields automatically to model to allow a behavior totally transparent, agree?

wenderjean avatar Jul 26 '17 18:07 wenderjean

@wenderjean seems like a good idea!

talyssonoc avatar Jul 26 '17 23:07 talyssonoc