Skip to content

Commit

Permalink
add strings to env
Browse files Browse the repository at this point in the history
  • Loading branch information
geeksilva97 committed Jan 13, 2025
1 parent dda982b commit ca148e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
3 changes: 3 additions & 0 deletions src/env_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
V(__dirname_string, "__dirname") \
V(ack_string, "ack") \
V(address_string, "address") \
V(source_db_string, "sourceDb") \
V(target_db_string, "targetDb") \
V(progress_string, "progress") \
V(aliases_string, "aliases") \
V(alpn_callback_string, "ALPNCallback") \
V(args_string, "args") \
Expand Down
20 changes: 6 additions & 14 deletions src/node_sqlite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,11 @@ inline MaybeLocal<Object> CreateSQLiteError(Isolate* isolate, int errcode) {
Environment* env = Environment::GetCurrent(isolate);
if (!String::NewFromUtf8(isolate, errstr).ToLocal(&js_errmsg) ||
!CreateSQLiteError(isolate, errstr).ToLocal(&e) ||
e->Set(isolate->GetCurrentContext(),
e->Set(env->context(),
env->errcode_string(),
Integer::New(isolate, errcode))
.IsNothing() ||
e->Set(isolate->GetCurrentContext(), env->errstr_string(), js_errmsg)
.IsNothing()) {
e->Set(env->context(), env->errstr_string(), js_errmsg).IsNothing()) {
return MaybeLocal<Object>();
}
return e;
Expand Down Expand Up @@ -772,16 +771,9 @@ void DatabaseSync::Backup(const FunctionCallbackInfo<Value>& args) {
}

Local<Object> options = args[1].As<Object>();
Local<String> progress_string =
FIXED_ONE_BYTE_STRING(env->isolate(), "progress");
Local<String> rate_string = FIXED_ONE_BYTE_STRING(env->isolate(), "rate");
Local<String> target_db_string =
FIXED_ONE_BYTE_STRING(env->isolate(), "targetDb");
Local<String> source_db_string =
FIXED_ONE_BYTE_STRING(env->isolate(), "sourceDb");

Local<Value> rateValue;
if (!options->Get(env->context(), rate_string).ToLocal(&rateValue)) {
if (!options->Get(env->context(), env->rate_string()).ToLocal(&rateValue)) {
return;
}

Expand All @@ -797,7 +789,7 @@ void DatabaseSync::Backup(const FunctionCallbackInfo<Value>& args) {
}

Local<Value> sourceDbValue;
if (!options->Get(env->context(), source_db_string)
if (!options->Get(env->context(), env->source_db_string())
.ToLocal(&sourceDbValue)) {
return;
}
Expand All @@ -815,7 +807,7 @@ void DatabaseSync::Backup(const FunctionCallbackInfo<Value>& args) {
}

Local<Value> targetDbValue;
if (!options->Get(env->context(), target_db_string)
if (!options->Get(env->context(), env->target_db_string())
.ToLocal(&targetDbValue)) {
return;
}
Expand All @@ -833,7 +825,7 @@ void DatabaseSync::Backup(const FunctionCallbackInfo<Value>& args) {
}

Local<Value> progressValue;
if (!options->Get(env->context(), progress_string)
if (!options->Get(env->context(), env->progress_string())
.ToLocal(&progressValue)) {
return;
}
Expand Down

0 comments on commit ca148e0

Please sign in to comment.