Skip to content

Instantly share code, notes, and snippets.

@lionxcr
Created July 14, 2020 10:23
Show Gist options
  • Save lionxcr/fcd995854b6a6e5024b3e28246832662 to your computer and use it in GitHub Desktop.
Save lionxcr/fcd995854b6a6e5024b3e28246832662 to your computer and use it in GitHub Desktop.
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