Skip to content

Commit

Permalink
sqlite: add filter and onConflict to env_properties.h
Browse files Browse the repository at this point in the history
  • Loading branch information
louwers committed Nov 17, 2024
1 parent c3cf3f3 commit 6f08540
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/env_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
V(fields_string, "fields") \
V(file_string, "file") \
V(filename_string, "filename") \
V(filter_string, "filter") \
V(fingerprint256_string, "fingerprint256") \
V(fingerprint512_string, "fingerprint512") \
V(fingerprint_string, "fingerprint") \
Expand Down Expand Up @@ -244,6 +245,7 @@
V(onchange_string, "onchange") \
V(onclienthello_string, "onclienthello") \
V(oncomplete_string, "oncomplete") \
V(onconflict_string, "onConflict") \
V(onconnection_string, "onconnection") \
V(ondone_string, "ondone") \
V(onerror_string, "onerror") \
Expand Down
15 changes: 3 additions & 12 deletions src/node_sqlite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,8 @@ void DatabaseSync::ApplyChangeset(const FunctionCallbackInfo<Value>& args) {
}

Local<Object> options = args[1].As<Object>();

Local<String> conflictKey =
String::NewFromUtf8(
env->isolate(), "onConflict", NewStringType::kNormal)
.ToLocalChecked();
Local<Value> conflictValue =
options->Get(env->context(), conflictKey).ToLocalChecked();
options->Get(env->context(), env->onconflict_string()).ToLocalChecked();

if (!conflictValue->IsUndefined()) {
if (!conflictValue->IsNumber()) {
Expand All @@ -471,13 +466,9 @@ void DatabaseSync::ApplyChangeset(const FunctionCallbackInfo<Value>& args) {
conflictCallback = [conflictInt]() -> int { return conflictInt; };
}

Local<String> filterKey =
String::NewFromUtf8(env->isolate(), "filter", NewStringType::kNormal)
.ToLocalChecked();

if (options->HasOwnProperty(env->context(), filterKey).FromJust()) {
if (options->HasOwnProperty(env->context(), env->filter_string()).FromJust()) {
Local<Value> filterValue =
options->Get(env->context(), filterKey).ToLocalChecked();
options->Get(env->context(), env->filter_string()).ToLocalChecked();

if (!filterValue->IsFunction()) {
THROW_ERR_INVALID_ARG_TYPE(
Expand Down

0 comments on commit 6f08540

Please sign in to comment.