package sihl
The modular functional web framework
Install
Dune Dependency
Authors
Maintainers
Sources
sihl-queue-0.1.7.tbz
sha256=a432c28b88610b8ef914aa93d1be5bf3ad4b357ebaa8e95848e981ea30611cd4
sha512=e85a2c2935973826ef29191d6a784dca53660c8df55a98174d7326a8a73865cf7f35bfae034b179d85f30bb809985da3c6d170608da2e9ac9763b8fd1f8a1a4e
doc/src/sihl.token/repo.ml.html
Source file repo.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
module Repository = Sihl_repository module Database = Sihl_database module Migration = Sihl_migration module MariaDb (MigrationService : Migration.Sig.SERVICE) : Sig.REPOSITORY = struct module Sql = struct let find_request = Caqti_request.find Caqti_type.string Model.t {sql| SELECT uuid, token_value, token_data, token_kind, status, expires_at, created_at FROM token_tokens WHERE token_tokens.token_value = ? |sql} ;; let find_opt ctx ~value = Database.Service.query ctx (fun (module Connection : Caqti_lwt.CONNECTION) -> Connection.find_opt find_request value |> Lwt.map Result.get_ok) ;; let find_by_id_request = Caqti_request.find Database.Id.t_string Model.t {sql| SELECT uuid, token_value, token_data, token_kind, status, expires_at, created_at FROM token_tokens WHERE token_tokens.uuid = ? |sql} ;; let find_by_id_opt ctx ~id = Database.Service.query ctx (fun (module Connection : Caqti_lwt.CONNECTION) -> Connection.find_opt find_by_id_request id |> Lwt.map Result.get_ok) ;; let insert_request = Caqti_request.exec Model.t {sql| INSERT INTO token_tokens ( uuid, token_value, token_data, token_kind, status, expires_at, created_at ) VALUES ( $1, $2, $3, $4, $5, $6, $7 ) |sql} ;; let insert ctx ~token = Database.Service.query ctx (fun (module Connection : Caqti_lwt.CONNECTION) -> Connection.exec insert_request token |> Lwt.map Result.get_ok) ;; let update_request = Caqti_request.exec Model.t {sql| UPDATE token_tokens SET token_data = $3, token_kind = $4, status = $5, expires_at = $6, created_at = $7 WHERE token_tokens.token_value = $2 |sql} ;; let update ctx ~token = Database.Service.query ctx (fun (module Connection : Caqti_lwt.CONNECTION) -> Connection.exec update_request token |> Lwt.map Result.get_ok) ;; let clean_request = Caqti_request.exec Caqti_type.unit "TRUNCATE token_tokens;" let clean ctx = Database.Service.query ctx (fun (module Connection : Caqti_lwt.CONNECTION) -> Connection.exec clean_request () |> Lwt.map Result.get_ok) ;; end module Migration = struct let fix_collation = Migration.create_step ~label:"fix collation" "SET collation_server = 'utf8mb4_unicode_ci'" ;; let create_tokens_table = Migration.create_step ~label:"create tokens table" {sql| CREATE TABLE IF NOT EXISTS token_tokens ( id BIGINT UNSIGNED AUTO_INCREMENT, uuid BINARY(16) NOT NULL, token_value VARCHAR(128) NOT NULL, token_data VARCHAR(1024), token_kind VARCHAR(128) NOT NULL, status VARCHAR(128) NOT NULL, expires_at TIMESTAMP NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id), CONSTRAINT unqiue_uuid UNIQUE KEY (uuid), CONSTRAINT unique_value UNIQUE KEY (token_value) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; |sql} ;; let migration () = Migration.(empty "tokens" |> add_step fix_collation |> add_step create_tokens_table) ;; end let register_migration () = MigrationService.register_migration (Migration.migration ()) let register_cleaner () = Repository.Service.register_cleaner Sql.clean let find_opt = Sql.find_opt let find_by_id_opt = Sql.find_by_id_opt let insert = Sql.insert let update = Sql.update end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>