getCollectionIfAllowed

@Query(value = ""SELECT c.* FROM " + COLLECTIONS_KEY + " as c WHERE c." + OWNER_KEY + "=:" + USER_IDENTIFIER_KEY + " AND c." + IDENTIFIER_KEY + "=:" + IDENTIFIER_KEY + " UNION " + "SELECT c.* FROM " + COLLECTIONS_KEY + " as c INNER JOIN " + COLLECTIONS_TEAMS_TABLE + " ON c." + IDENTIFIER_KEY + " = " + COLLECTIONS_TEAMS_TABLE + "." + COLLECTION_IDENTIFIER_KEY + " INNER JOIN " + MEMBERS_KEY + " ON " + MEMBERS_KEY + "." + TEAM_IDENTIFIER_KEY + " WHERE " + MEMBERS_KEY + "." + OWNER_KEY + "=:" + USER_IDENTIFIER_KEY + " AND c." + IDENTIFIER_KEY + "=:" + IDENTIFIER_KEY", nativeQuery = true)
abstract fun getCollectionIfAllowed(@Param(value = "user_id") userId: String, @Param(value = "id") collectionId: String): LinksCollection

Method to execute the query to get a collection if the user is authorized

Return

the collection if the user is authorized as LinksCollection

Parameters

userId

: the identifier of the user

collectionId

: the collection identifier