Commit 0fc1900e authored by Ivanq's avatar Ivanq

ZeroDB: Update

parent d88692c7
......@@ -8,8 +8,8 @@ class ZeroDB {
this.fs = new ZeroFS(page);
}
query(query) {
return this.page.cmd("dbQuery", [query])
query(query, placeholders) {
return this.page.cmd("dbQuery", [query, placeholders])
.then(result => {
if(result.error) {
return Promise.reject(result.error);
......@@ -138,4 +138,31 @@ class ZeroDB {
);
});
}
getJsonID(path, version) {
let where;
if(version == 1) {
where = {
path: path
};
} else if(version == 2) {
path = path.split("/");
where = {
directory: path.slice(0, -1).join("/"),
file_name: path.slice(-1)[0]
};
} else if(version == 3) {
path = path.split("/");
where = {
site: path[0],
directory: path.slice(1, -1).join("/"),
file_name: path.slice(-1)[0]
};
}
return this.query("SELECT * FROM json WHERE ?", where)
.then(json => {
return json.length ? json[0].json_id : -1;
});
}
};
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment