diff --git a/apps/appstore/app.js b/apps/appstore/app.js index 02719736..ecc537e4 100644 --- a/apps/appstore/app.js +++ b/apps/appstore/app.js @@ -1,6 +1,6 @@ async function get_apps() { let results = {}; - await ssb.sqlStream(` + await ssb.sqlAsync(` SELECT messages.* FROM messages_fts('"application/tildefriends"') JOIN messages ON messages.rowid = messages_fts.rowid @@ -52,4 +52,4 @@ async function main() { `); } -main(); \ No newline at end of file +main(); diff --git a/src/ssb.js.c b/src/ssb.js.c index 651b8df6..be38ff16 100644 --- a/src/ssb.js.c +++ b/src/ssb.js.c @@ -303,41 +303,6 @@ static JSValue _tf_ssb_closeConnection(JSContext* context, JSValueConst this_val return connection ? JS_TRUE : JS_FALSE; } -typedef struct _sqlStream_callback_t -{ - JSContext* context; - JSValue callback; -} sqlStream_callback_t; - -static void _tf_ssb_sqlStream_callback(JSValue row, void* user_data) -{ - sqlStream_callback_t* info = user_data; - JSValue response = JS_Call(info->context, info->callback, JS_UNDEFINED, 1, &row); - tf_util_report_error(info->context, response); - JS_FreeValue(info->context, response); -} - -static JSValue _tf_ssb_sqlStream(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv) -{ - JSValue result = JS_NULL; - tf_ssb_t* ssb = JS_GetOpaque(this_val, _tf_ssb_classId); - if (ssb) - { - const char* query = JS_ToCString(context, argv[0]); - if (query) - { - sqlStream_callback_t info = - { - .context = context, - .callback = argv[2], - }; - result = tf_ssb_db_visit_query(ssb, query, argv[1], _tf_ssb_sqlStream_callback, &info); - JS_FreeCString(context, query); - } - } - return result; -} - typedef struct _sql_work_t { uv_work_t request; @@ -1319,7 +1284,6 @@ void tf_ssb_register(JSContext* context, tf_ssb_t* ssb) JS_SetPropertyStr(context, object, "getConnection", JS_NewCFunction(context, _tf_ssb_getConnection, "getConnection", 1)); JS_SetPropertyStr(context, object, "closeConnection", JS_NewCFunction(context, _tf_ssb_closeConnection, "closeConnection", 1)); JS_SetPropertyStr(context, object, "forgetStoredConnection", JS_NewCFunction(context, _tf_ssb_forgetStoredConnection, "forgetStoredConnection", 1)); - JS_SetPropertyStr(context, object, "sqlStream", JS_NewCFunction(context, _tf_ssb_sqlStream, "sqlStream", 3)); JS_SetPropertyStr(context, object, "sqlAsync", JS_NewCFunction(context, _tf_ssb_sqlAsync, "sqlAsync", 3)); JS_SetPropertyStr(context, object, "storeMessage", JS_NewCFunction(context, _tf_ssb_storeMessage, "storeMessage", 1)); JS_SetPropertyStr(context, object, "getBroadcasts", JS_NewCFunction(context, _tf_ssb_getBroadcasts, "getBroadcasts", 0));