我已经设置了一个表格,用于存储时间戳,并配置了书架以使用它们。通常情况下,一切都按照预期进行,书架会处理时间戳,但我有一个需要指定时间戳的情况,但当我尝试这样做时,值被忽略,当前日期被使用。
我试图将我的用例简化到必要的内容:
var Author = Bookshelf.Model.extend({
tableName: 'authors',
hasTimestamps: ['created_at', 'updated_at'],
bookAuthors: function(){
return this.hasMany(require('.book_authors'));
},
associateBookWithAuthor(bookId,timestamp) {
return self.related('bookAuthors').create({
book_id: bookId,
updated_at: timestamp, // ignored by bookshelf
created_at: timestamp // also ignored
})
}
}
我仍希望在常规用例下保留hasTimestamps
配置。是否有可能让Bookshelf允许我覆盖时间戳行为?