mirror of
https://github.com/bitwarden/server.git
synced 2025-04-07 05:58:13 -05:00
18 lines
565 B
Transact-SQL
18 lines
565 B
Transact-SQL
CREATE VIEW [dbo].[CollectionUserCollectionDetailsView]
|
|
AS
|
|
SELECT
|
|
C.[Id] Id,
|
|
C.[OrganizationId],
|
|
C.[Name],
|
|
OU.[UserId],
|
|
OU.[Id] AS [OrganizationUserId],
|
|
CASE WHEN OU.[AccessAll] = 0 AND CU.[ReadOnly] = 1 THEN 1 ELSE 0 END [ReadOnly]
|
|
FROM
|
|
[dbo].[Collection] C
|
|
INNER JOIN
|
|
[dbo].[OrganizationUser] OU ON C.[OrganizationId] = OU.[OrganizationId]
|
|
LEFT JOIN
|
|
[dbo].[CollectionUser] CU ON OU.[AccessAll] = 0 AND CU.[CollectionId] = C.[Id] AND CU.[OrganizationUserId] = [OU].[Id]
|
|
WHERE
|
|
OU.[AccessAll] = 1
|
|
OR CU.[Id] IS NOT NULL |