我试图通过Peewee 3.2.2中额外列的中间表建立多种关系,如下所示:
ThroughDeferred = DeferredThroughModel()
class Playlist(BaseModel):
...
movies = ManyToManyField(Movie, backref='playlists', through_model=ThroughDeferred)
class Movie(BaseModel):
name = CharField(max_length=100)
class PlaylistMovie(BaseModel):
playlist = ForeignKeyField(column_name='playlist_id', field='id', model=Playlist)
movie = ForeignKeyField(column_name='movie_id', field='id', model=Movie)
position = PositiveSmallIntegerField(default=1)
class Meta:
table_name = 'playlist_movie_relation'
ThroughDeferred.set_model(PlaylistMovie)
然后,在查询时我得到的是没有位置的相关电影数据列表。
list(playlist.movies.dicts())
> [{name: 'blah', id: 3}, ...]
如何获取playlist.movies中的位置数据?
答案 0 :(得分:1)
这应该有效:
bot.on('callback_query', function onCallbackQuery(callbackQuery) {
if(!didWeRemoveHisKeyboard(callbackQuery.from.id))
removeHisKeyboard(callbackQuery)
//then handle the user response
})
removeHisKeyboard = function(callbackQuery){
bot.editMessageText(callbackQuery.message.text,
{message_id:callbackQuery.message.message_id , chat_id:callbackQuery.from.id,
reply_markup: {
remove_keyboard: true
}}).catch((err) => {
//some error handling
}).then(function(res){
if(res)
addThisChatToHandledList(callbackQuery.from.id)
})
}