u
This commit is contained in:
63
src/providers/mssql/queries/modelvfs.js
Normal file
63
src/providers/mssql/queries/modelvfs.js
Normal file
@@ -0,0 +1,63 @@
|
||||
export const MODELVFS_COLUMNS = `
|
||||
id,
|
||||
company_id,
|
||||
name,
|
||||
mime,
|
||||
meta,
|
||||
created_at,
|
||||
updated_at
|
||||
`;
|
||||
|
||||
export const GET_BY_COMPANY_AND_NAME = `
|
||||
SELECT
|
||||
${MODELVFS_COLUMNS},
|
||||
content
|
||||
FROM modelvfs
|
||||
WHERE company_id = @companyId AND name = @name
|
||||
`;
|
||||
|
||||
export const GET_META_BY_COMPANY_AND_NAME = `
|
||||
SELECT
|
||||
${MODELVFS_COLUMNS}
|
||||
FROM modelvfs
|
||||
WHERE company_id = @companyId AND name = @name
|
||||
`;
|
||||
|
||||
export const LIST_BY_COMPANY = `
|
||||
SELECT
|
||||
${MODELVFS_COLUMNS}
|
||||
FROM modelvfs
|
||||
WHERE company_id = @companyId
|
||||
ORDER BY name ASC
|
||||
`;
|
||||
|
||||
export const UPSERT = `
|
||||
MERGE modelvfs AS target
|
||||
USING (SELECT @companyId AS company_id, @name AS name) AS src
|
||||
ON target.company_id = src.company_id AND target.name = src.name
|
||||
WHEN MATCHED THEN
|
||||
UPDATE SET mime = @mime, content = @content, meta = @meta, updated_at = SYSUTCDATETIME()
|
||||
WHEN NOT MATCHED THEN
|
||||
INSERT (company_id, name, mime, content, meta)
|
||||
VALUES (@companyId, @name, @mime, @content, @meta)
|
||||
OUTPUT
|
||||
INSERTED.id,
|
||||
INSERTED.company_id,
|
||||
INSERTED.name,
|
||||
INSERTED.mime,
|
||||
INSERTED.meta,
|
||||
INSERTED.created_at,
|
||||
INSERTED.updated_at;
|
||||
`;
|
||||
|
||||
export const DELETE_BY_COMPANY_AND_NAME = `
|
||||
DELETE FROM modelvfs
|
||||
OUTPUT DELETED.id
|
||||
WHERE company_id = @companyId AND name = @name
|
||||
`;
|
||||
|
||||
export const DELETE_ALL_BY_COMPANY = `
|
||||
DELETE FROM modelvfs
|
||||
OUTPUT DELETED.id
|
||||
WHERE company_id = @companyId
|
||||
`;
|
||||
Reference in New Issue
Block a user