Documentation
¶
Index ¶
Constants ¶
const ( // UserUsernamesUniqueUsername is the constraint name for the unique username constraint on the user_usernames table UserUsernamesUniqueUsername = "user_usernames_unique_username" // UserUsernamesUniqueUserID is the constraint name for the unique user ID constraint on the user_usernames table UserUsernamesUniqueUserID = "user_usernames_unique_user_id" // UserEmailsUniqueEmail is the constraint name for the unique email constraint on the user_emails table UserEmailsUniqueEmail = "user_emails_unique_email" // UserEmailsUniqueUserID is the constraint name for the unique user ID constraint on the user_emails table UserEmailsUniqueUserID = "user_emails_unique_user_id" // UserPhoneNumbersUniquePhoneNumber is the constraint name for the unique phone number constraint on the user_phone_numbers table UserPhoneNumbersUniquePhoneNumber = "user_phone_numbers_unique_phone_number" // UserPhoneNumbersUniqueUserID is the constraint name for the unique user ID constraint on the user_phone_numbers table UserPhoneNumbersUniqueUserID = "user_phone_numbers_unique_user_id" // UserTagsUniqueUserIDName is the constraint name for the unique user ID and name constraint on the user_tags table UserTagsUniqueUserIDName = "user_tags_unique_user_id_name" // UserPasswordHashesUniqueUserID is the constraint name for the unique user ID constraint on the user_password_hashes table UserPasswordHashesUniqueUserID = "user_password_hashes_unique_user_id" // UserResetPasswordsUniqueUserID is the constraint name for the unique user ID constraint on the user_reset_passwords table UserResetPasswordsUniqueUserID = "user_reset_passwords_unique_user_id" // UserEmailVerificationsUniqueUserEmailID is the constraint name for the unique user email ID constraint on the user_email_verifications table UserEmailVerificationsUniqueUserEmailID = "user_email_verifications_unique_user_email_id" // UserPhoneNumberVerificationsUniqueUserPhoneNumberID is the constraint name for the unique user phone number ID constraint on the user_phone_number_verifications table UserPhoneNumberVerificationsUniqueUserPhoneNumberID = "user_phone_number_verifications_unique_user_phone_number_id" // UserRefreshTokensUniqueParentUserRefreshTokenID is the constraint name for the unique parent user refresh token ID constraint on the user_refresh_tokens table UserRefreshTokensUniqueParentUserRefreshTokenID = "user_refresh_tokens_unique_parent_user_refresh_token_id" // UserAccessTokensUniqueUserRefreshTokenID is the constraint name for the unique user refresh token ID constraint on the user_access_tokens table UserAccessTokensUniqueUserRefreshTokenID = "user_access_tokens_unique_user_refresh_token_id" // User2FATOTPUniqueUserID is the constraint name for the unique user ID constraint on the user_2fa_totp table User2FATOTPUniqueUserID = "user_2fa_totp_unique_user_id" // UserNoteTagsUniqueUserNoteIDUserTagID is the constraint name for the unique user note ID and user tag ID constraint on the user_note_tags table UserNoteTagsUniqueUserNoteIDUserTagID = "user_note_tags_unique_user_note_id_user_tag_id" )
const ( // CreateGetUserRefreshTokenByIDFn is the query to create the function to get user refresh token by ID CreateGetUserRefreshTokenByIDFn = `` /* 645-byte string literal not displayed */ // CreateListUserRefreshTokensFn is the query to create the function to list user refresh tokens CreateListUserRefreshTokensFn = `` /* 754-byte string literal not displayed */ // CreateListUserTokensFn is the query to create the function to list user tokens CreateListUserTokensFn = `` /* 573-byte string literal not displayed */ // CreateListUserTagsFn is the query to create the function to list user tags CreateListUserTagsFn = `` /* 561-byte string literal not displayed */ // CreateListUserNoteVersionsFn is the query to create the function to list user note versions CreateListUserNoteVersionsFn = `` /* 542-byte string literal not displayed */ // CreateListUserNoteTagsFn is the query to create the function to list user note tags CreateListUserNoteTagsFn = `` /* 683-byte string literal not displayed */ // CreateSyncUserNoteVersionsByLastSyncedAtFn is the query to create the function to sync user note versions by last synced at CreateSyncUserNoteVersionsByLastSyncedAtFn = `` /* 1051-byte string literal not displayed */ // CreateSyncUserTagsByLastSyncedAtFn is the query to create the function to sync user tags by last synced at CreateSyncUserTagsByLastSyncedAtFn = `` /* 840-byte string literal not displayed */ // CreateSyncUserNoteTagsByLastSyncedAtFn is the query to create the function to sync user note tags by last synced at CreateSyncUserNoteTagsByLastSyncedAtFn = `` /* 963-byte string literal not displayed */ // CreateSyncUserNotesByLastSyncedAtFn is the query to create the function to sync user notes by last synced at CreateSyncUserNotesByLastSyncedAtFn = `` /* 2324-byte string literal not displayed */ // CreateGetUserTagByIDFn is the query to create the function to get user tag by tag ID CreateGetUserTagByIDFn = `` /* 620-byte string literal not displayed */ // CreateGetUserNoteVersionByIDFn is the query to create the function to get user note version by note version ID CreateGetUserNoteVersionByIDFn = `` /* 809-byte string literal not displayed */ // CreateGetUserNoteByIDFn is the query to create the function to get user note by note ID CreateGetUserNoteByIDFn = `` /* 1315-byte string literal not displayed */ // CreateGetLogInInformationFn is the query to create the function to get log in information CreateGetLogInInformationFn = `` /* 1433-byte string literal not displayed */ )
const ( // CreateGetUserEmailIDProc is the query to create the stored procedure to get user email ID by user ID CreateGetUserEmailIDProc = `` /* 335-byte string literal not displayed */ // CreateRevokeUserEmailVerificationTokenProc is the query to create the stored procedure to revoke user email verification token CreateRevokeUserEmailVerificationTokenProc = `` /* 362-byte string literal not displayed */ // CreateSendEmailVerificationTokenProc is the query to create the stored procedure to send email verification token CreateSendEmailVerificationTokenProc = `` /* 725-byte string literal not displayed */ // CreateSignUpProc is the query to create the stored procedure to sign-up CreateSignUpProc = `` /* 1350-byte string literal not displayed */ // CreateRevokeUser2FATOTPProc is the query to create the stored procedure to revoke user 2FA TOTP CreateRevokeUser2FATOTPProc = `` /* 287-byte string literal not displayed */ // CreateGenerateUserTokensProc is the query to create the stored procedure to generate user tokens CreateGenerateUserTokensProc = `` /* 958-byte string literal not displayed */ // CreateRevokeUserTokensByIDProc is the query to create the stored procedure to revoke user tokens by ID CreateRevokeUserTokensByIDProc = `` /* 670-byte string literal not displayed */ // CreateRefreshTokenProc is the query to create the stored procedure to refresh token CreateRefreshTokenProc = `` /* 747-byte string literal not displayed */ // CreateRevokeUserTokensProc is the query to create the stored procedure to revoke user tokens CreateRevokeUserTokensProc = `` /* 499-byte string literal not displayed */ // CreateGetUserAccessTokenIDByUserRefreshTokenIDProc is the query to create the stored procedure to get user access token ID by user refresh token ID CreateGetUserAccessTokenIDByUserRefreshTokenIDProc = `` /* 449-byte string literal not displayed */ // CreateRegisterFailedLogInAttemptProc is the query to create the stored procedure to register failed log in attempt CreateRegisterFailedLogInAttemptProc = `` /* 452-byte string literal not displayed */ // CreateGetUser2FATOTPProc is the query to create the stored procedure to get user 2FA TOTP by user ID CreateGetUser2FATOTPProc = `` /* 565-byte string literal not displayed */ // CreateGetUserEmailProc is the query to create the stored procedure to get user email by user ID CreateGetUserEmailProc = `` /* 325-byte string literal not displayed */ // CreateGenerate2FATOTPUrlProc is the query to create the stored procedure to generate 2FA TOTP URL CreateGenerate2FATOTPUrlProc = `` /* 1263-byte string literal not displayed */ // CreateIsRefreshTokenValidProc is the query to create the stored procedure to check if the refresh token is valid CreateIsRefreshTokenValidProc = `` /* 720-byte string literal not displayed */ // CreateIsAccessTokenValidProc is the query to create the stored procedure to check if the access token is valid CreateIsAccessTokenValidProc = `` /* 706-byte string literal not displayed */ // CreateUseUser2FARecoveryCodeProc is the query to create the stored procedure to use user 2FA TOTP recovery code CreateUseUser2FARecoveryCodeProc = `` /* 1330-byte string literal not displayed */ // CreateRevokeUser2FARecoveryCodesProc is the query to create the stored procedure to revoke user 2FA recovery codes CreateRevokeUser2FARecoveryCodesProc = `` /* 383-byte string literal not displayed */ // CreateVerify2FATOTPProc is the query to create verify 2FA TOTP CreateVerify2FATOTPProc = `` /* 334-byte string literal not displayed */ // CreateVerifyEmailProc is the query to create the stored procedure to verify email CreateVerifyEmailProc = `` /* 1127-byte string literal not displayed */ // CreateIsUserEmailVerifiedProc is the query to create the stored procedure to check if the user email is verified CreateIsUserEmailVerifiedProc = `` /* 376-byte string literal not displayed */ // CreatePreSendEmailVerificationTokenProc is the query to create the stored procedure to pre-send email verification token CreatePreSendEmailVerificationTokenProc = `` /* 691-byte string literal not displayed */ // CreateRevokeUserEmailProc is the query to create the stored procedure to revoke user email CreateRevokeUserEmailProc = `` /* 558-byte string literal not displayed */ // CreateChangeEmailProc is the query to create the stored procedure to change email CreateChangeEmailProc = `` /* 910-byte string literal not displayed */ // CreateRevokeUserResetPasswordTokenProc is the query to create the stored procedure to revoke user reset password token CreateRevokeUserResetPasswordTokenProc = `` /* 324-byte string literal not displayed */ CreateForgotPasswordProc = `` /* 1041-byte string literal not displayed */ // CreateRevokeUserPasswordHashProc is the query to create the stored procedure to revoke user password hash CreateRevokeUserPasswordHashProc = `` /* 316-byte string literal not displayed */ // CreateGetUserIDByResetPasswordTokenProc is the query to create the stored procedure to get user ID by reset password token CreateGetUserIDByResetPasswordTokenProc = `` /* 475-byte string literal not displayed */ // CreateResetPasswordProc is the query to create the stored procedure to reset password CreateResetPasswordProc = `` /* 1066-byte string literal not displayed */ // CreateGetUserPasswordHashProc is the query to create the stored procedure to get user password hash CreateGetUserPasswordHashProc = `` /* 403-byte string literal not displayed */ // CreateChangePasswordProc is the query to create the stored procedure to change password CreateChangePasswordProc = `` /* 586-byte string literal not displayed */ // CreateRevokeUserUsernameProc is the query to create the stored procedure to revoke user username CreateRevokeUserUsernameProc = `` /* 288-byte string literal not displayed */ // CreateRevokeUserPhoneNumberProc is the query to create the stored procedure to revoke user phone number CreateRevokeUserPhoneNumberProc = `` /* 648-byte string literal not displayed */ // CreateDeleteUserProc is the query to create the stored procedure to delete user CreateDeleteUserProc = `` /* 901-byte string literal not displayed */ // CreateChangeUsernameProc is the query to create the stored procedure to change username CreateChangeUsernameProc = `` /* 356-byte string literal not displayed */ // CreateGetUserBasicInfoProc is the query to create the stored procedure to get user basic info CreateGetUserBasicInfoProc = `` /* 497-byte string literal not displayed */ // CreateUpdateProfileProc is the query to create the stored procedure to update profile CreateUpdateProfileProc = `` /* 809-byte string literal not displayed */ // CreateGetUserPhoneNumberProc is the query to create the stored procedure to get user phone number by user ID CreateGetUserPhoneNumberProc = `` /* 389-byte string literal not displayed */ // CreateGetUserUsernameProc is the query to create the stored procedure to get user username by user ID CreateGetUserUsernameProc = `` /* 353-byte string literal not displayed */ // CreateHasUser2FAEnabledProc is the query to create the stored procedure to check if the user has 2FA enabled CreateHasUser2FAEnabledProc = `` /* 358-byte string literal not displayed */ // CreateIsUserPhoneNumberVerifiedProc is the query to create the stored procedure to check if the user phone number is verified CreateIsUserPhoneNumberVerifiedProc = `` /* 434-byte string literal not displayed */ // CreateGetMyProfileProc is the query to create the stored procedure to get my profile CreateGetMyProfileProc = `` /* 1225-byte string literal not displayed */ // CreateCreateUserTagProc is the query to create the stored procedure to create user tag CreateCreateUserTagProc = `` /* 329-byte string literal not displayed */ // CreateUpdateUserTagProc is the query to create the stored procedure to update user tag CreateUpdateUserTagProc = `` /* 385-byte string literal not displayed */ // CreateDeleteUserTagProc is the query to create the stored procedure to delete user tag CreateDeleteUserTagProc = `` /* 326-byte string literal not displayed */ // CreateDeleteUserTagsByUserIDProc is the query to create the stored procedure to delete user tags by user ID CreateDeleteUserTagsByUserIDProc = `` /* 275-byte string literal not displayed */ // CreateUpdateUserNotePinProc is the query to create the stored procedure to update user note pin CreateUpdateUserNotePinProc = `` /* 443-byte string literal not displayed */ // CreateUpdateUserNoteArchiveProc is the query to create the stored procedure to update user note archive CreateUpdateUserNoteArchiveProc = `` /* 458-byte string literal not displayed */ // CreateUpdateUserNoteTrashProc is the query to create the stored procedure to update user note trash CreateUpdateUserNoteTrashProc = `` /* 450-byte string literal not displayed */ // CreateUpdateUserNoteStarProc is the query to create the stored procedure to update user note star CreateUpdateUserNoteStarProc = `` /* 447-byte string literal not displayed */ // CreateCreateUserNoteVersionProc is the query to create the stored procedure to create user note version CreateCreateUserNoteVersionProc = `` /* 901-byte string literal not displayed */ // CreateDeleteUserNoteVersionProc is the query to create the stored procedure to delete user note version CreateDeleteUserNoteVersionProc = `` /* 528-byte string literal not displayed */ // CreateDeleteUserNoteVersionsByNoteIDProc is the query to create the stored procedure to delete user note versions by note ID CreateDeleteUserNoteVersionsByNoteIDProc = `` /* 477-byte string literal not displayed */ // CreateValidateUserTagsIDProc is the query to create the stored procedure to validate user tags ID CreateValidateUserTagsIDProc = `` /* 455-byte string literal not displayed */ // CreateAddUserNoteTagsProc is the query to create the stored procedure to add user note tags CreateAddUserNoteTagsProc = `` /* 597-byte string literal not displayed */ // CreateDeleteUserNoteTagsByNoteIDProc is the query to create the stored procedure to delete user note tags by note ID CreateDeleteUserNoteTagsByNoteIDProc = `` /* 429-byte string literal not displayed */ // CreateCreateUserNoteProc is the query to create the stored procedure to create user note CreateCreateUserNoteProc = `` /* 1291-byte string literal not displayed */ // CreateCreateUser2FARecoveryCodesProc is the query to create the stored procedure to create user TOTP recovery codes CreateCreateUser2FARecoveryCodesProc = `` /* 768-byte string literal not displayed */ // CreateDeleteUserNoteProc is the query to create the stored procedure to delete user note CreateDeleteUserNoteProc = `` /* 656-byte string literal not displayed */ // CreateDeleteUserNotesByUserIDProc is the query to create the stored procedure to delete user notes by user ID CreateDeleteUserNotesByUserIDProc = `` /* 542-byte string literal not displayed */ // CreateRemoveUserNoteTagsProc is the query to create the stored procedure to remove user note tags CreateRemoveUserNoteTagsProc = `` /* 553-byte string literal not displayed */ // CreateUpdateUserNoteProc is the query to create the stored procedure to update user note CreateUpdateUserNoteProc = `` /* 856-byte string literal not displayed */ // CreateListUserNotesProc is the query to create the stored procedure to list user notes CreateListUserNotesProc = `` /* 367-byte string literal not displayed */ // CreateRevokeUser2FAEmailCodeProc is the query to create the stored procedure to revoke user 2FA email code CreateRevokeUser2FAEmailCodeProc = `` /* 364-byte string literal not displayed */ // CreateCreateUser2FAEmailCodeProc is the query to create the stored procedure to create user 2FA email code CreateCreateUser2FAEmailCodeProc = `` /* 493-byte string literal not displayed */ // CreateUseUser2FAEmailCodeProc is the query to create the stored procedure to use user 2FA email code CreateUseUser2FAEmailCodeProc = `` /* 949-byte string literal not displayed */ // CreateEnableUser2FAProc is the query to create the stored procedure to enable user 2FA CreateEnableUser2FAProc = `` /* 771-byte string literal not displayed */ // CreateDisableUser2FAProc is the query to create the stored procedure to disable user 2FA CreateDisableUser2FAProc = `` /* 701-byte string literal not displayed */ // CreateSendUser2FAEmailCodeProc is the query to create the stored procedure to send user 2FA email code CreateSendUser2FAEmailCodeProc = `` /* 1405-byte string literal not displayed */ // CreateHasUser2FATOTPEnabledProc is the query to create the stored procedure to check if the user has 2FA TOTP enabled CreateHasUser2FATOTPEnabledProc = `` /* 399-byte string literal not displayed */ // CreateGetUser2FAMethodsProc is the query to create the stored procedure to get user 2FA methods CreateGetUser2FAMethodsProc = `` /* 420-byte string literal not displayed */ )
const ( // CreateUsers is the SQL query to create the users table CreateUsers = `` /* 347-byte string literal not displayed */ // CreateUserFailedLogInAttempts is the SQL query to create the user_failed_log_in_attempts table CreateUserFailedLogInAttempts = `` /* 325-byte string literal not displayed */ // CreateUser2FA is the SQL query to create the user_2fa table CreateUser2FA = `` /* 226-byte string literal not displayed */ // CreateUser2FARecoveryCodes is the SQL query to create the user_2fa_recovery_codes table CreateUser2FARecoveryCodes = `` /* 302-byte string literal not displayed */ // CreateUser2FAEmailCodes is the SQL query to create the user_2fa_email_codes table CreateUser2FAEmailCodes = `` /* 319-byte string literal not displayed */ // CreateUserNotes is the SQL query to create the user_notes table CreateUserNotes = `` /* 434-byte string literal not displayed */ // CreateUserNoteVersions is the SQL query to create the user_note_versions table CreateUserNoteVersions = `` /* 297-byte string literal not displayed */ )
Variables ¶
var ( // CreateUserUsernames is the SQL query to create the user_usernames table CreateUserUsernames = fmt.Sprintf( ` CREATE TABLE IF NOT EXISTS user_usernames ( id BIGSERIAL PRIMARY KEY, user_id BIGINT NOT NULL, username VARCHAR(50) NOT NULL, assigned_at TIMESTAMP NOT NULL DEFAULT NOW(), revoked_at TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS %s ON user_usernames (username) WHERE revoked_at IS NULL; CREATE UNIQUE INDEX IF NOT EXISTS %s ON user_usernames (user_id) WHERE revoked_at IS NULL; `, UserUsernamesUniqueUsername, UserUsernamesUniqueUserID, ) // CreateUserEmails is the SQL query to create the user_emails table CreateUserEmails = fmt.Sprintf( ` CREATE TABLE IF NOT EXISTS user_emails ( id BIGSERIAL PRIMARY KEY, user_id BIGINT NOT NULL, email VARCHAR(100) NOT NULL, assigned_at TIMESTAMP NOT NULL DEFAULT NOW(), revoked_at TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS %s ON user_emails (email) WHERE revoked_at IS NULL; CREATE UNIQUE INDEX IF NOT EXISTS %s ON user_emails (user_id) WHERE revoked_at IS NULL; `, UserEmailsUniqueEmail, UserEmailsUniqueUserID, ) // CreateUserPasswordHashes is the SQL query to create the user_password_hashes table CreateUserPasswordHashes = fmt.Sprintf( ` CREATE TABLE IF NOT EXISTS user_password_hashes ( id BIGSERIAL PRIMARY KEY, user_id BIGINT NOT NULL, password_hash VARCHAR(255) NOT NULL, assigned_at TIMESTAMP NOT NULL DEFAULT NOW(), revoked_at TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS %s ON user_password_hashes (user_id) WHERE revoked_at IS NULL; `, UserPasswordHashesUniqueUserID, ) // CreateUserPhoneNumbers is the SQL query to create the user_phone_numbers table CreateUserPhoneNumbers = fmt.Sprintf( ` CREATE TABLE IF NOT EXISTS user_phone_numbers ( id BIGSERIAL PRIMARY KEY, user_id BIGINT NOT NULL, phone_number VARCHAR(20) UNIQUE NOT NULL, assigned_at TIMESTAMP NOT NULL DEFAULT NOW(), revoked_at TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS %s ON user_phone_numbers (phone_number) WHERE revoked_at IS NULL; CREATE UNIQUE INDEX IF NOT EXISTS %s ON user_phone_numbers (user_id) WHERE revoked_at IS NULL; `, UserPhoneNumbersUniquePhoneNumber, UserPhoneNumbersUniqueUserID, ) // CreateUserTags is the SQL query to create the user_tags table CreateUserTags = fmt.Sprintf( ` CREATE TABLE IF NOT EXISTS user_tags ( id BIGSERIAL PRIMARY KEY, user_id BIGINT NOT NULL, name VARCHAR(50) NOT NULL, created_at TIMESTAMP NOT NULL DEFAULT NOW(), updated_at TIMESTAMP NOT NULL DEFAULT NOW(), deleted_at TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS %s ON user_tags (user_id, name) WHERE deleted_at IS NULL; `, UserTagsUniqueUserIDName, ) // CreateUserResetPasswords is the SQL query to create the user_reset_passwords table CreateUserResetPasswords = fmt.Sprintf( ` CREATE TABLE IF NOT EXISTS user_reset_passwords ( id BIGSERIAL PRIMARY KEY, user_id BIGINT NOT NULL, reset_token VARCHAR(255) UNIQUE NOT NULL, created_at TIMESTAMP NOT NULL DEFAULT NOW(), expires_at TIMESTAMP NOT NULL, revoked_at TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS %s ON user_reset_passwords (user_id) WHERE revoked_at IS NULL; `, UserResetPasswordsUniqueUserID, ) // CreateUserEmailVerifications is the SQL query to create the user_email_verifications table CreateUserEmailVerifications = fmt.Sprintf( ` CREATE TABLE IF NOT EXISTS user_email_verifications ( id BIGSERIAL PRIMARY KEY, user_email_id BIGINT NOT NULL, verification_token VARCHAR(255) UNIQUE NOT NULL, created_at TIMESTAMP NOT NULL DEFAULT NOW(), expires_at TIMESTAMP NOT NULL, verified_at TIMESTAMP, revoked_at TIMESTAMP, FOREIGN KEY (user_email_id) REFERENCES user_emails(id) ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS %s ON user_email_verifications (user_email_id) WHERE revoked_at IS NULL; `, UserEmailVerificationsUniqueUserEmailID, ) // CreateUserPhoneNumberVerifications is the SQL query to create the user_phone_number_verifications table CreateUserPhoneNumberVerifications = fmt.Sprintf( ` CREATE TABLE IF NOT EXISTS user_phone_number_verifications ( id BIGSERIAL PRIMARY KEY, user_phone_number_id BIGINT NOT NULL, verification_code VARCHAR(10) NOT NULL, created_at TIMESTAMP NOT NULL DEFAULT NOW(), expires_at TIMESTAMP NOT NULL, verified_at TIMESTAMP, revoked_at TIMESTAMP, FOREIGN KEY (user_phone_number_id) REFERENCES user_phone_numbers(id) ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS %s ON user_phone_number_verifications (user_phone_number_id) WHERE revoked_at IS NULL; `, UserPhoneNumberVerificationsUniqueUserPhoneNumberID, ) // CreateUserRefreshTokens is the SQL query to create the user_refresh_tokens table CreateUserRefreshTokens = fmt.Sprintf( ` CREATE TABLE IF NOT EXISTS user_refresh_tokens ( id BIGSERIAL PRIMARY KEY, user_id BIGINT NOT NULL, parent_user_refresh_token_id BIGINT, ip_address VARCHAR(15) NOT NULL, issued_at TIMESTAMP NOT NULL DEFAULT NOW(), expires_at TIMESTAMP NOT NULL, revoked_at TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY (parent_user_refresh_token_id) REFERENCES user_refresh_tokens(id) ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS %s ON user_refresh_tokens (parent_user_refresh_token_id) WHERE parent_user_refresh_token_id IS NOT NULL; `, UserRefreshTokensUniqueParentUserRefreshTokenID, ) // CreateUserAccessTokens is the SQL query to create the user_access_tokens table CreateUserAccessTokens = fmt.Sprintf( ` CREATE TABLE IF NOT EXISTS user_access_tokens ( id BIGSERIAL PRIMARY KEY, user_id BIGINT NOT NULL, user_refresh_token_id BIGINT NOT NULL, issued_at TIMESTAMP NOT NULL DEFAULT NOW(), expires_at TIMESTAMP NOT NULL, revoked_at TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY (user_refresh_token_id) REFERENCES user_refresh_tokens(id) ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS %s ON user_access_tokens (user_refresh_token_id); `, UserAccessTokensUniqueUserRefreshTokenID, ) // CreateUser2FATOTP is the SQL query to create the user_2fa_totp table CreateUser2FATOTP = fmt.Sprintf( ` CREATE TABLE IF NOT EXISTS user_2fa_totp ( id BIGSERIAL PRIMARY KEY, user_id BIGINT NOT NULL, secret VARCHAR(255) NOT NULL, created_at TIMESTAMP NOT NULL DEFAULT NOW(), verified_at TIMESTAMP, revoked_at TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS %s ON user_2fa_totp (user_id) WHERE revoked_at IS NULL; `, User2FATOTPUniqueUserID, ) // CreateUserNoteTags is the SQL query to create the user_note_tags table CreateUserNoteTags = fmt.Sprintf( ` CREATE TABLE IF NOT EXISTS user_note_tags ( id BIGSERIAL PRIMARY KEY, user_note_id BIGINT NOT NULL, user_tag_id BIGINT NOT NULL, assigned_at TIMESTAMP NOT NULL DEFAULT NOW(), deleted_at TIMESTAMP, FOREIGN KEY (user_note_id) REFERENCES user_notes(id) ON DELETE CASCADE, FOREIGN KEY (user_tag_id) REFERENCES user_tags(id) ON DELETE CASCADE ); CREATE UNIQUE INDEX IF NOT EXISTS %s ON user_note_tags (user_note_id, user_tag_id) WHERE deleted_at IS NULL; `, UserNoteTagsUniqueUserNoteIDUserTagID, ) )
var ( // GetUserRefreshTokenByIDFn is the query to get a refresh token by ID GetUserRefreshTokenByIDFn = "SELECT * FROM get_user_refresh_token_by_id($1, $2);" // ListUserRefreshTokensFn is the query to list user refresh tokens ListUserRefreshTokensFn = "SELECT * FROM list_user_refresh_tokens($1);" // ListUserTokensFn is the query to list user tokens ListUserTokensFn = "SELECT * FROM list_user_tokens($1);" // ListUserTagsFn is the query to list user tags ListUserTagsFn = "SELECT * FROM list_user_tags($1);" // ListUserNoteVersionsFn is the query to list user note versions ListUserNoteVersionsFn = "SELECT * FROM list_user_note_versions($1, $2);" // ListUserNoteTagsFn is the query to list user note tags ListUserNoteTagsFn = "SELECT * FROM list_user_note_tags($1, $2);" // SyncUserNoteVersionsByLastSyncedAtFn is the query to sync user note versions by last synced at SyncUserNoteVersionsByLastSyncedAtFn = "SELECT * FROM sync_user_note_versions_by_last_synced_at($1, $2, $3);" // SyncUserNotesByLastSyncedAtFn is the query to sync user notes by last synced at SyncUserNotesByLastSyncedAtFn = "SELECT * FROM sync_user_notes_by_last_synced_at($1, $2, $3);" // SyncUserNoteTagsByLastSyncedAtFn is the query to sync user note tags by last synced at SyncUserNoteTagsByLastSyncedAtFn = "SELECT * FROM sync_user_note_tags_by_last_synced_at($1, $2);" // SyncUserTagsByLastSyncedAtFn is the query to sync user tags by last synced at SyncUserTagsByLastSyncedAtFn = "SELECT * FROM sync_user_tags_by_last_synced_at($1, $2);" // GetUserTagByIDFn is the query to get user tag by tag ID GetUserTagByIDFn = "SELECT * FROM get_user_tag_by_id($1, $2, $3)" // GetUserNoteVersionByIDFn is the query to get user note version by note version ID GetUserNoteVersionByIDFn = "SELECT * FROM get_user_note_version_by_id($1, $2)" // GetUserNoteByIDFn is the query to get user note by note ID GetUserNoteByIDFn = "SELECT * FROM get_user_note_by_id($1, $2)" // GetLogInInformationFn is the query to get the login information GetLogInInformationFn = "SELECT * FROM get_log_in_information($1, $2, $3, $4);" )
var ( // SignUpProc is the query to call the stored procedure to sign-up SignUpProc = "CALL sign_up($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)" // RevokeUser2FATOTPProc is the query to call the stored procedure to revoke user 2FA TOTP RevokeUser2FATOTPProc = "CALL revoke_user_2fa_totp($1)" // GenerateUserTokensProc is the query to call the stored procedure to generate user tokens GenerateUserTokensProc = "CALL generate_user_tokens($1, $2, $3, $4, $5, $6, $7)" // RevokeUserTokensByIDProc is the query to call the stored procedure to revoke user tokens by ID RevokeUserTokensByIDProc = "CALL revoke_user_tokens_by_id($1, $2)" // RefreshTokenProc is the query to call the stored procedure to refresh token RefreshTokenProc = "CALL refresh_token($1, $2, $3, $4, $5, $6, $7)" // RevokeUserTokensProc is the query to call the stored procedure to revoke user tokens RevokeUserTokensProc = "CALL revoke_user_tokens($1)" // GetUserAccessTokenByUserRefreshTokenIDProc is the query to call the stored procedure to get user access token by user refresh token ID GetUserAccessTokenByUserRefreshTokenIDProc = "CALL get_user_access_token_by_user_refresh_token_id($1, $2)" // RegisterFailedLogInAttemptProc is the query to call the stored procedure to register failed login attempt RegisterFailedLogInAttemptProc = "CALL register_failed_log_in_attempt($1, $2, $3, $4)" // GetUser2FATOTPProc is the query to call the stored procedure to get user 2FA TOTP GetUser2FATOTPProc = "CALL get_user_2fa_totp($1, $2, $3, $4)" // GetUserEmailProc is the query to call the stored procedure to get user email GetUserEmailProc = "CALL get_user_email($1, $2)" // Generate2FATOTPUrlProc is the query to call the stored procedure to generate 2FA TOTP URL Generate2FATOTPUrlProc = "CALL generate_2fa_totp_url($1, $2, $3, $4, $5, $6, $7)" // IsRefreshTokenValidProc is the query to call the stored procedure to check if the refresh token is valid IsRefreshTokenValidProc = "CALL is_refresh_token_valid($1, $2, $3, $4)" // IsAccessTokenValidProc is the query to call the stored procedure to check if the access token is valid IsAccessTokenValidProc = "CALL is_access_token_valid($1, $2, $3, $4)" // RevokeUser2FARecoveryCodesProc is the query to call the stored procedure to revoke user 2FA recovery codes RevokeUser2FARecoveryCodesProc = "CALL revoke_user_2fa_recovery_codes($1)" // UseUser2FARecoveryCodeProc is the query to call the stored procedure to use user 2FA recovery code UseUser2FARecoveryCodeProc = "CALL use_user_2fa_recovery_code($1, $2, $3, $4)" // Verify2FATOTPProc is the query to call the stored procedure to verify 2FA TOTP Verify2FATOTPProc = "CALL verify_2fa_totp($1)" // SendEmailVerificationTokenProc is the query to call the stored procedure to send email verification token SendEmailVerificationTokenProc = "CALL send_email_verification_token($1, $2, $3)" // GetUserEmailIDProc is the query to call the stored procedure to get user email ID GetUserEmailIDProc = "CALL get_user_email_id($1, $2)" // VerifyEmailProc is the query to call the stored procedure to verify email VerifyEmailProc = "CALL verify_email($1, $2, $3)" // IsUserEmailVerifiedProc is the query to call the stored procedure to check if the user email is verified IsUserEmailVerifiedProc = "CALL is_user_email_verified($1, $2)" // PreSendEmailVerificationTokenProc is the query to call the stored procedure to pre-send email verification token PreSendEmailVerificationTokenProc = "CALL pre_send_email_verification_token($1, $2, $3, $4, $5, $6)" // RevokeUserEmailProc is the query to call the stored procedure to revoke user email RevokeUserEmailProc = "CALL revoke_user_email($1)" // ChangeEmailProc is the query to call the stored procedure to change email ChangeEmailProc = "CALL change_email($1, $2, $3, $4, $5, $6)" // ForgotPasswordProc is the query to call the stored procedure to forgot password ForgotPasswordProc = "CALL forgot_password($1, $2, $3, $4, $5, $6)" // RevokeUserResetPasswordTokenProc is the query to call the stored procedure to revoke user reset password token RevokeUserResetPasswordTokenProc = "CALL revoke_user_reset_password_token($1)" // RevokeUserPasswordHashProc is the query to call the stored procedure to revoke user password hash RevokeUserPasswordHashProc = "CALL revoke_user_password_hash($1)" // ResetPasswordProc is the query to call the stored procedure to reset password ResetPasswordProc = "CALL reset_password($1, $2, $3, $4, $5)" // ChangePasswordProc is the query to call the stored procedure to change password ChangePasswordProc = "CALL change_password($1, $2, $3)" // GetUserPasswordHashProc is the query to call the stored procedure to get user password hash GetUserPasswordHashProc = "CALL get_user_password_hash($1, $2)" // RevokeUserUsernameProc is the query to call the stored procedure to revoke username RevokeUserUsernameProc = "CALL revoke_user_username($1)" // RevokeUserPhoneNumberProc is the query to call the stored procedure to revoke user phone number RevokeUserPhoneNumberProc = "CALL revoke_user_phone_number($1)" // DeleteUserProc is the query to call the stored procedure to delete user DeleteUserProc = "CALL delete_user($1)" // ChangeUsernameProc is the query to call the stored procedure to change username ChangeUsernameProc = "CALL change_username($1, $2)" // UpdateProfileProc is the query to call the stored procedure to update profile UpdateProfileProc = "CALL update_profile($1, $2, $3, $4)" // RevokeUserEmailVerificationTokenProc is the query to call the stored procedure to revoke user email verification token RevokeUserEmailVerificationTokenProc = "CALL revoke_user_email_verification_token($1)" // GetUserPhoneNumberProc is the query to call the stored procedure to get user phone number GetUserPhoneNumberProc = "CALL get_user_phone_number($1, $2)" // GetUserUsernameProc is the query to call the stored procedure to get user username GetUserUsernameProc = "CALL get_user_username($1, $2)" // IsUserPhoneNumberVerifiedProc is the query to call the stored procedure to check if the user phone number is verified IsUserPhoneNumberVerifiedProc = "CALL is_user_phone_number_verified($1, $2)" // HasUser2FAEnabledProc is the query to call the stored procedure to check if the user has 2FA enabled HasUser2FAEnabledProc = "CALL has_user_2fa_enabled($1, $2)" // GetMyProfileProc is the query to call the stored procedure to get my profile GetMyProfileProc = "CALL get_my_profile($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)" // GetUserBasicInfoProc is the query to call the stored procedure to get user basic info GetUserBasicInfoProc = "CALL get_user_basic_info($1, $2, $3, $4)" // CreateUserTagProc is the query to call the stored procedure to create user tag CreateUserTagProc = "CALL create_user_tag($1, $2, $3)" // DeleteUserTagProc is the query to call the stored procedure to delete user tag DeleteUserTagProc = "CALL delete_user_tag($1, $2)" // UpdateUserTagProc is the query to call the stored procedure to update user tag UpdateUserTagProc = "CALL update_user_tag($1, $2, $3)" // UpdateUserNoteTrashProc is the query to call the stored procedure to update user note trash UpdateUserNoteTrashProc = "CALL update_user_note_trash($1, $2, $3)" // UpdateUserNoteStarProc is the query to call the stored procedure to update user note star UpdateUserNoteStarProc = "CALL update_user_note_star($1, $2, $3)" // UpdateUserNoteArchiveProc is the query to call the stored procedure to update user note archive UpdateUserNoteArchiveProc = "CALL update_user_note_archive($1, $2, $3)" // UpdateUserNotePinProc is the query to call the stored procedure to update user note pin UpdateUserNotePinProc = "CALL update_user_note_pin($1, $2, $3)" // CreateUserNoteVersionProc is the query to call the stored procedure to create user note version CreateUserNoteVersionProc = "CALL create_user_note_version($1, $2, $3, $4, $5)" // DeleteUserNoteVersionProc is the query to call the stored procedure to delete user note version DeleteUserNoteVersionProc = "CALL delete_user_note_version($1, $2)" // CreateUserNoteProc is the query to call the stored procedure to create user note CreateUserNoteProc = "CALL create_user_note($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)" // AddUserNoteTagsProc is the query to call the stored procedure to add user note tags AddUserNoteTagsProc = "CALL add_user_note_tags($1, $2, $3)" // ValidateUserTagsIDProc is the query to call the stored procedure to validate user tags ID ValidateUserTagsIDProc = "CALL validate_user_tags_id($1, $2, $3)" // CreateUser2FARecoveryCodesProc is the query to call the stored procedure to create user 2FA recovery codes CreateUser2FARecoveryCodesProc = "CALL create_user_2fa_recovery_codes($1, $2, $3)" // DeleteUserNoteProc is the query to call the stored procedure to delete user note DeleteUserNoteProc = "CALL delete_user_note($1, $2)" // RemoveUserNoteTagsProc is the query to call the stored procedure to remove user note tags RemoveUserNoteTagsProc = "CALL remove_user_note_tags($1, $2, $3)" // UpdateUserNoteProc is the query to call the stored procedure to update user note UpdateUserNoteProc = "CALL update_user_note($1, $2, $3, $4)" // ListUserNotesProc is the query to call the stored procedure to list user notes ListUserNotesProc = "CALL list_user_notes($1, $2)" // RevokeUser2FAEmailCodeProc is the query to call the stored procedure to revoke user 2FA email code RevokeUser2FAEmailCodeProc = "CALL revoke_user_2fa_email_code($1)" // CreateUser2FAEmailCodeProc is the query to call the stored procedure to create user 2FA email code CreateUser2FAEmailCodeProc = "CALL create_user_2fa_email_code($1, $2)" // UseUser2FAEmailCodeProc is the query to call the stored procedure to use user 2FA email code UseUser2FAEmailCodeProc = "CALL use_user_2fa_email_code($1, $2, $3)" // EnableUser2FAProc is the query to call the stored procedure to enable user 2FA EnableUser2FAProc = "CALL enable_user_2fa($1, $2, $3, $4)" // DisableUser2FAProc is the query to call the stored procedure to disable user 2FA DisableUser2FAProc = "CALL disable_user_2fa($1, $2)" // SendUser2FAEmailCodeProc is the query to call the stored procedure to send user 2FA email code SendUser2FAEmailCodeProc = "CALL send_user_2fa_email_code($1, $2, $3, $4, $5, $6, $7, $8, $9)" // HasUser2FATOTPEnabledProc is the query to call the stored procedure to check if the user has 2FA TOTP enabled HasUser2FATOTPEnabledProc = "CALL has_user_2fa_totp_enabled($1, $2)" // GetUser2FAMethodsProc is the query to call the stored procedure to get user 2FA methods GetUser2FAMethodsProc = "CALL get_user_2fa_methods($1, $2, $3)" // GetUserIDByResetPasswordTokenProc is the query to call the stored procedure to get user ID by reset password token GetUserIDByResetPasswordTokenProc = "CALL get_user_id_by_reset_password_token($1, $2)" // DeleteUserNoteVersionsByNoteIDProc is the query to call the stored procedure to delete user note versions by note ID DeleteUserNoteVersionsByNoteIDProc = "CALL delete_user_note_versions_by_note_id($1, $2)" // DeleteUserNoteTagsByNoteIDProc is the query to call the stored procedure to delete user note tags by note ID DeleteUserNoteTagsByNoteIDProc = "CALL delete_user_note_tags_by_note_id($1, $2)" // DeleteUserTagsByUserIDProc is the query to call the stored procedure to delete user tags by user ID DeleteUserTagsByUserIDProc = "CALL delete_user_tags_by_user_id($1)" // DeleteUserNotesByUserIDProc is the query to call the stored procedure to delete user notes by user ID DeleteUserNotesByUserIDProc = "CALL delete_user_notes_by_user_id($1)" )
Functions ¶
This section is empty.
Types ¶
type SyncUserNote ¶
type SyncUserNote struct {
Title *string `json:"title,omitempty"`
Color *string `json:"color,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
PinnedAt *time.Time `json:"pinned_at,omitempty"`
StarredAt *time.Time `json:"starred_at,omitempty"`
ArchivedAt *time.Time `json:"archived_at,omitempty"`
TrashedAt *time.Time `json:"trashed_at,omitempty"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
SyncNoteVersions []*UserNoteVersionWithID `json:"sync_note_versions"`
SyncNoteTags []*UserNoteTag `json:"sync_note_tags"`
}
SyncUserNote is the response DTO for the sync user note
type SyncUserNoteWithID ¶
type SyncUserNoteWithID struct {
ID int64 `json:"id"`
SyncUserNote
}
SyncUserNoteWithID is the response DTO for the sync user note with ID
type UserNote ¶
type UserNote struct {
Title string `json:"title"`
NoteTagsID []string `json:"note_tags_id"`
Color *string `json:"color,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
PinnedAt *time.Time `json:"pinned_at,omitempty"`
StarredAt *time.Time `json:"starred_at,omitempty"`
ArchivedAt *time.Time `json:"archived_at,omitempty"`
TrashedAt *time.Time `json:"trashed_at,omitempty"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
LatestNoteVersionID *int64 `json:"latest_note_version_id,omitempty"`
}
UserNote is the response DTO for the user note
type UserNoteTag ¶
type UserNoteTag struct {
TagID int64 `json:"tag_id"`
AssignedAt time.Time `json:"assigned_at"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
}
UserNoteTag is the response DTO for the user note tag
type UserNoteTagWithID ¶
type UserNoteTagWithID struct {
ID int64 `json:"id"`
UserNoteTag
}
UserNoteTagWithID is the response DTO for the user note tag with ID
type UserNoteVersion ¶
type UserNoteVersion struct {
NoteID *int64 `json:"note_id,omitempty"`
EncryptedContent string `json:"encrypted_content"`
CreatedAt time.Time `json:"created_at"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
}
UserNoteVersion is the response DTO for the user note version
type UserNoteVersionWithID ¶
type UserNoteVersionWithID struct {
ID int64 `json:"id"`
UserNoteVersion
}
UserNoteVersionWithID is the response DTO for the user note version with ID
type UserNoteWithID ¶
UserNoteWithID is the response DTO for the user note with ID
type UserRefreshToken ¶
type UserRefreshToken struct {
IssuedAt time.Time `json:"issued_at"`
ExpiresAt time.Time `json:"expires_at"`
RevokedAt *time.Time `json:"revoked_at,omitempty"`
IPAddress string `json:"ip_address"`
}
UserRefreshToken is the response DTO for the user refresh token
type UserRefreshTokenWithID ¶
type UserRefreshTokenWithID struct {
ID int64 `json:"id"`
UserRefreshToken
}
UserRefreshTokenWithID is the response DTO for the user refresh token with ID
type UserTag ¶
type UserTag struct {
Name string `json:"name"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
}
UserTag is the response DTO for the user tag
type UserTagWithID ¶
UserTagWithID is the response DTO for the user tag with ID