Giter VIP home page Giter VIP logo

Comments (9)

scottwrobinson avatar scottwrobinson commented on July 18, 2024 2

Okay so I'm finally getting back to this. Thinking about it some more, I think it would be a nice inclusion, just not enabled by default. I believe features like this should be opt-in instead of opt-out.

The timestamps property would likely have to be set using a static method. Like this:

class User extends Document {
    static timestamps() {
        return true;
    }
}

You could also return names of the created_at/updated_at fields for more customization:

class User extends Document {
    static timestamps() {
        return {
            created_at: 'createdTime',
            updated_at: 'updatedTime'
        };
    }
}

Doing it in the constructor, as shown by @vfreitas-, wouldn't work because then we couldn't access the timestamps property in any static methods (like User.findOneAndUpdate()).

Thoughts?

from camo.

devdebonair avatar devdebonair commented on July 18, 2024 2

Was a pull request submitted for this yet?

from camo.

vfreitas- avatar vfreitas- commented on July 18, 2024 1

You can have a boolean variable, that will decide if the timestamp fields will be added.

class User extends Document {
    constructor() {
        //... 

        this.timestamps = false; //default = true

        //...
    }
}

from camo.

michaeljota avatar michaeljota commented on July 18, 2024 1

Maybe not to be enable by default, but that it's a way to go.

from camo.

michaeljota avatar michaeljota commented on July 18, 2024

👍 +1

from camo.

scottwrobinson avatar scottwrobinson commented on July 18, 2024

I'll consider it. I hesitate to add data by default to people's models, but
maybe it can be an option.

I'll leave this open for discussion for a bit to gauge interest.

Thanks!

Scott
On Jan 29, 2016 4:01 PM, "Michael De Abreu" [email protected]
wrote:

[image: 👍] +1


Reply to this email directly or view it on GitHub
#40 (comment).

from camo.

samirbr avatar samirbr commented on July 18, 2024

What about use a timestamp decorator?

@timestamp
class User extends Document {
}

You could pass timestamp field names too:

@timestamp({
  created_at: 'createdTime',
  updated_at: 'updatedTime'
})
class Use extends Document {
}

from camo.

michaeljota avatar michaeljota commented on July 18, 2024

I don't think ES6 have decorators. For what I understand after googling,
decorators are suppose to come in 2016 with ES2016(ES7).

However, for a long proposal that would be a good idea.

2016-05-31 19:51 GMT-04:00 Samir El Aouar [email protected]:

What about use a timestamp decorator?

@timestamp
class User extends Document {
}

You could pass timestamp field names too:

@timestamp({
created_at: 'createdTime',
updated_at: 'updatedTime'
})
class Use extends Document {
}


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#40 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AKBWABMfZIaNHx8kkcIla_N6dQQvoOE6ks5qHMmNgaJpZM4HNCJn
.

from camo.

scottwrobinson avatar scottwrobinson commented on July 18, 2024

Yep, ES6 does not have decorators. As nice as this feature would be, we'd
then have to require application code to use a transpiler like Babel, which
does not work with Camo's goal.

I'd like to implement this feature in ES6 soon, but if anyone would like to
submit a PR for it sooner, I'd be happy to accept.
On May 31, 2016 7:50 PM, "Michael De Abreu" [email protected]
wrote:

I don't think ES6 have decorators. For what I understand after googling,
decorators are suppose to come in 2016 with ES2016(ES7).

However, for a long proposal that would be a good idea.

2016-05-31 19:51 GMT-04:00 Samir El Aouar [email protected]:

What about use a timestamp decorator?

@timestamp
class User extends Document {
}

You could pass timestamp field names too:

@timestamp({
created_at: 'createdTime',
updated_at: 'updatedTime'
})
class Use extends Document {
}


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#40 (comment)
,
or mute the thread
<
https://github.com/notifications/unsubscribe/AKBWABMfZIaNHx8kkcIla_N6dQQvoOE6ks5qHMmNgaJpZM4HNCJn

.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#40 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ACz-bzEpoiZANjb7GPf5SLMXJkeVOpiQks5qHR2ngaJpZM4HNCJn
.

from camo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.