NoTimestamp trait throws error
willvincent opened this issue · 4 comments
Was the newly added NoTimestamp trait tested? It throws an error when I try to use it:
TypeError: Property description must be an object: c
at Function.defineProperties (<anonymous>)
This is due to incorrect syntax, Object.defineProperties accepts two parameters, not three.
Object.defineProperties(Model, 'createdAtColumn', {
get () { return null }
})
I suspect this was intended to be Object.defineProperty()
which would accept that syntax.
To use Object.defineProperties, the second prop must be an object of properties. This would be the correct syntax:
Object.defineProperties(Model, {
createdAtColumn: {
get: () => null,
},
updatedAtColumn: {
get: () => null,
},
})
Hey @willvincent! 👋
Actually, there's a little typo in this one, should be defineProperty
instead of defineProperties
.
Here's the one I'm using in production:
https://github.com/Lausanne-eSports/api.els.team/blob/develop/app/Models/Traits/NoTimestamp.js
Yeah, it'll work with defineProperties if done as I did in my pull request though :)
Yes, thanks!
Could you make the same PR for https://github.com/adonisjs/adonis-api-app?
Sure