- attributes: {
- include: attributesInclude
- },
- offset: options.start,
- limit: options.count,
- order: getSort(options.sort),
- where: {
+ offset: parameters.start,
+ limit: parameters.count,
+ order: getSort(parameters.sort)
+ }
+
+ return VideoChannelModel
+ .scope({
+ method: [ ScopeNames.FOR_API, { actorId } as AvailableForListOptions ]
+ })
+ .findAndCountAll(query)
+ .then(({ rows, count }) => {
+ return { total: count, data: rows }
+ })
+ }
+
+ static searchForApi (options: Pick<AvailableForListOptions, 'actorId' | 'search' | 'host' | 'handles'> & {
+ start: number
+ count: number
+ sort: string
+ }) {
+ let attributesInclude: any[] = [ literal('0 as similarity') ]
+ let where: WhereOptions
+
+ if (options.search) {
+ const escapedSearch = VideoChannelModel.sequelize.escape(options.search)
+ const escapedLikeSearch = VideoChannelModel.sequelize.escape('%' + options.search + '%')
+ attributesInclude = [ createSimilarityAttribute('VideoChannelModel.name', options.search) ]
+
+ where = {