You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.5 KiB
72 lines
1.5 KiB
package ydb
|
|
|
|
const (
|
|
createQuery = `
|
|
PRAGMA TablePathPrefix("%s");
|
|
CREATE TABLE file_meta (
|
|
dir_hash int64,
|
|
name Utf8,
|
|
directory Utf8,
|
|
meta String,
|
|
PRIMARY KEY (dir_hash, name)
|
|
);`
|
|
|
|
insertQuery = `
|
|
DECLARE $dir_hash int64;
|
|
DECLARE $name AS Utf8;
|
|
DECLARE $directory AS Utf8;
|
|
DECLARE $meta AS String;
|
|
|
|
UPSERT INTO file_meta
|
|
(dir_hash, name, directory, meta)
|
|
VALUES
|
|
($dir_hash, $name, $directory, $meta);`
|
|
|
|
updateQuery = `
|
|
DECLARE $dir_hash int64;
|
|
DECLARE $name AS Utf8;
|
|
DECLARE $directory AS Utf8;
|
|
DECLARE $meta AS String;
|
|
|
|
REPLACE INTO file_meta
|
|
(dir_hash, name, directory, meta)
|
|
VALUES
|
|
($dir_hash, $name, $directory, $meta)
|
|
COMMIT;`
|
|
|
|
deleteQuery = `
|
|
DECLARE $dir_hash int64;
|
|
DECLARE $name AS Utf8;
|
|
|
|
DELETE FROM file_meta
|
|
WHERE dir_hash == $dir_hash AND name == $name;
|
|
COMMIT;`
|
|
|
|
findQuery = `
|
|
DECLARE $dir_hash int64;
|
|
DECLARE $name AS Utf8;
|
|
|
|
SELECT meta
|
|
FROM file_meta
|
|
WHERE dir_hash == $dir_hash AND name == $name;`
|
|
|
|
deleteFolderChildrenQuery = `
|
|
DECLARE $dir_hash int64;
|
|
DECLARE $directory AS Utf8;
|
|
|
|
DELETE FROM file_meta
|
|
WHERE dir_hash == $dir_hash AND directory == $directory;
|
|
COMMIT;`
|
|
|
|
ListDirectoryQuery = `
|
|
DECLARE $dir_hash int64;
|
|
DECLARE $directory AS Utf8;
|
|
DECLARE $start_name AS Utf8;
|
|
DECLARE $prefix AS Utf8;
|
|
DECLARE $limit AS int64;
|
|
|
|
SELECT name, meta
|
|
FROM file_meta
|
|
WHERE dir_hash == $dir_hash AND directory == $directory and name %v $start_name and name LIKE '$prefix%'
|
|
ORDER BY name ASC LIMIT $limit;`
|
|
)
|