This repository has been archived on 2022-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
DevOpsOpenHack/apis/userprofile/data/queries.js

66 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-11-03 20:41:13 +00:00
exports.INSERT_USER_PROFILE =
`INSERT INTO userprofiles \
(\
Id,\
FirstName,\
LastName,\
UserId,\
ProfilePictureUri,\
Rating,\
Ranking,\
TotalDistance,\
TotalTrips,\
TotalTime,\
HardStops,\
HardAccelerations,\
FuelConsumption,\
MaxSpeed,\
CreatedAt,\
UpdatedAt,\
Deleted\
) \
SELECT \
Id,\
FirstName,\
LastName,\
UserId,\
ProfilePictureUri,\
Rating,\
Ranking,\
TotalDistance,\
TotalTrips,\
TotalTime,\
HardStops,\
HardAccelerations,\
FuelConsumption,\
MaxSpeed,\
GETDATE(),\
GETDATE(),\
Deleted \
FROM OPENJSON(@UserProfileJson) \
WITH (
Id nvarchar(128),\
FirstName nvarchar(max),\
LastName nvarchar(max),\
UserId nvarchar(max),\
ProfilePictureUri nvarchar(max),\
Rating int,\
Ranking int,\
TotalDistance float(53),\
TotalTrips bigint,\
TotalTime bigint,\
HardStops bigint,\
HardAccelerations bigint,\
FuelConsumption float(53),\
MaxSpeed float(53),\
Deleted bit\
) AS JSON`;
exports.SELECT_USER_PROFILE_BY_ID=
'select * from userprofiles where id = @user_profile_id FOR JSON PATH';
exports.SELECT_USER_PROFILES=
'select * FROM userprofiles FOR JSON PATH';
exports.DELETE_USER_PROFILE=
'UPDATE userprofiles SET Deleted = 1 WHERE id = @user_profile_id';