forked from cory/tildefriends
A little format, as a treat.
This commit is contained in:
parent
2c03496373
commit
b40f72443a
@ -278,8 +278,8 @@ static void _database_exchange_work(tf_ssb_t* ssb, void* user_data)
|
|||||||
else if (sqlite3_prepare(db, "UPDATE properties SET value = ?1 WHERE id = ?2 AND key = ?3 AND value = ?4", -1, &statement, NULL) == SQLITE_OK)
|
else if (sqlite3_prepare(db, "UPDATE properties SET value = ?1 WHERE id = ?2 AND key = ?3 AND value = ?4", -1, &statement, NULL) == SQLITE_OK)
|
||||||
{
|
{
|
||||||
if (sqlite3_bind_text(statement, 1, work->value, work->value_length, NULL) == SQLITE_OK && sqlite3_bind_text(statement, 2, work->id, -1, NULL) == SQLITE_OK &&
|
if (sqlite3_bind_text(statement, 1, work->value, work->value_length, NULL) == SQLITE_OK && sqlite3_bind_text(statement, 2, work->id, -1, NULL) == SQLITE_OK &&
|
||||||
sqlite3_bind_text(statement, 3, work->key, work->key_length, NULL) == SQLITE_OK && sqlite3_bind_text(statement, 4, work->expected, work->expected_length, NULL) == SQLITE_OK &&
|
sqlite3_bind_text(statement, 3, work->key, work->key_length, NULL) == SQLITE_OK &&
|
||||||
sqlite3_step(statement) == SQLITE_DONE)
|
sqlite3_bind_text(statement, 4, work->expected, work->expected_length, NULL) == SQLITE_OK && sqlite3_step(statement) == SQLITE_DONE)
|
||||||
{
|
{
|
||||||
work->result = sqlite3_changes(db) != 0;
|
work->result = sqlite3_changes(db) != 0;
|
||||||
}
|
}
|
||||||
@ -314,8 +314,7 @@ static JSValue _database_exchange(JSContext* context, JSValueConst this_val, int
|
|||||||
{
|
{
|
||||||
tf_ssb_t* ssb = tf_task_get_ssb(database->task);
|
tf_ssb_t* ssb = tf_task_get_ssb(database->task);
|
||||||
database_exchange_t* work = tf_malloc(sizeof(database_exchange_t));
|
database_exchange_t* work = tf_malloc(sizeof(database_exchange_t));
|
||||||
*work = (database_exchange_t)
|
*work = (database_exchange_t) {
|
||||||
{
|
|
||||||
.id = tf_strdup(database->id),
|
.id = tf_strdup(database->id),
|
||||||
};
|
};
|
||||||
work->key = JS_ToCStringLen(context, &work->key_length, argv[0]);
|
work->key = JS_ToCStringLen(context, &work->key_length, argv[0]);
|
||||||
@ -376,8 +375,7 @@ static JSValue _database_remove(JSContext* context, JSValueConst this_val, int a
|
|||||||
const char* key = JS_ToCStringLen(context, &key_length, argv[0]);
|
const char* key = JS_ToCStringLen(context, &key_length, argv[0]);
|
||||||
|
|
||||||
database_remove_t* work = tf_malloc(sizeof(database_remove_t) + key_length + 1);
|
database_remove_t* work = tf_malloc(sizeof(database_remove_t) + key_length + 1);
|
||||||
*work = (database_remove_t)
|
*work = (database_remove_t) {
|
||||||
{
|
|
||||||
.id = tf_strdup(database->id),
|
.id = tf_strdup(database->id),
|
||||||
.key_length = key_length,
|
.key_length = key_length,
|
||||||
};
|
};
|
||||||
@ -499,8 +497,7 @@ static void _database_get_like_work(tf_ssb_t* ssb, void* user_data)
|
|||||||
sqlite3* db = tf_ssb_acquire_db_reader(ssb);
|
sqlite3* db = tf_ssb_acquire_db_reader(ssb);
|
||||||
if (sqlite3_prepare(db, "SELECT key, value FROM properties WHERE id = ? AND KEY LIKE ?", -1, &statement, NULL) == SQLITE_OK)
|
if (sqlite3_prepare(db, "SELECT key, value FROM properties WHERE id = ? AND KEY LIKE ?", -1, &statement, NULL) == SQLITE_OK)
|
||||||
{
|
{
|
||||||
if (sqlite3_bind_text(statement, 1, work->id, -1, NULL) == SQLITE_OK &&
|
if (sqlite3_bind_text(statement, 1, work->id, -1, NULL) == SQLITE_OK && sqlite3_bind_text(statement, 2, work->pattern, -1, NULL) == SQLITE_OK)
|
||||||
sqlite3_bind_text(statement, 2, work->pattern, -1, NULL) == SQLITE_OK)
|
|
||||||
{
|
{
|
||||||
while (sqlite3_step(statement) == SQLITE_ROW)
|
while (sqlite3_step(statement) == SQLITE_ROW)
|
||||||
{
|
{
|
||||||
@ -554,8 +551,7 @@ static JSValue _database_get_like(JSContext* context, JSValueConst this_val, int
|
|||||||
{
|
{
|
||||||
tf_ssb_t* ssb = tf_task_get_ssb(database->task);
|
tf_ssb_t* ssb = tf_task_get_ssb(database->task);
|
||||||
database_get_like_t* work = tf_malloc(sizeof(database_get_like_t));
|
database_get_like_t* work = tf_malloc(sizeof(database_get_like_t));
|
||||||
*work = (database_get_like_t)
|
*work = (database_get_like_t) {
|
||||||
{
|
|
||||||
.id = tf_strdup(database->id),
|
.id = tf_strdup(database->id),
|
||||||
.pattern = JS_ToCString(context, argv[0]),
|
.pattern = JS_ToCString(context, argv[0]),
|
||||||
};
|
};
|
||||||
@ -620,8 +616,7 @@ static JSValue _databases_list(JSContext* context, JSValueConst this_val, int ar
|
|||||||
tf_task_t* task = tf_task_get(context);
|
tf_task_t* task = tf_task_get(context);
|
||||||
tf_ssb_t* ssb = tf_task_get_ssb(task);
|
tf_ssb_t* ssb = tf_task_get_ssb(task);
|
||||||
databases_list_t* work = tf_malloc(sizeof(databases_list_t));
|
databases_list_t* work = tf_malloc(sizeof(databases_list_t));
|
||||||
*work = (databases_list_t)
|
*work = (databases_list_t) {
|
||||||
{
|
|
||||||
.pattern = JS_ToCString(context, argv[0]),
|
.pattern = JS_ToCString(context, argv[0]),
|
||||||
};
|
};
|
||||||
JSValue result = JS_NewPromiseCapability(context, work->promise);
|
JSValue result = JS_NewPromiseCapability(context, work->promise);
|
||||||
|
Loading…
Reference in New Issue
Block a user