Created
July 14, 2020 10:23
-
-
Save lionxcr/fcd995854b6a6e5024b3e28246832662 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sequelize = hook.app.get('sequelizeClient'); | |
const queryExample = ``` | |
UPDATE a | |
SET [Role]= 'Admin' | |
FROM UserRoles a | |
WHERE a.[Role]= 'Administrator' | |
AND NOT EXISTS | |
( | |
SELECT NULL | |
FROM dbo.UserRoles b | |
WHERE b.[User] = a.[User] AND b.[Role] = 'Admin' | |
); | |
``` | |
sequelize.query(queryExample, { | |
type: sequelize.QueryTypes.UPDATE | |
}).then(function (response) { | |
//response | |
}).catch((error) { | |
//error | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment