@@ -2659,11 +2659,13 @@ Local<FunctionTemplate> SQLTagStore::GetConstructorTemplate(Environment* env) {
26592659 SetProtoMethod (isolate, tmpl, " iterate" , Iterate);
26602660 SetProtoMethod (isolate, tmpl, " run" , Run);
26612661 SetProtoMethod (isolate, tmpl, " clear" , Clear);
2662- SetProtoMethod (isolate, tmpl, " size" , Size);
2663- SetSideEffectFreeGetter (
2664- isolate, tmpl, FIXED_ONE_BYTE_STRING (isolate, " capacity" ), Capacity);
2662+ SetSideEffectFreeGetter (isolate,
2663+ tmpl,
2664+ FIXED_ONE_BYTE_STRING (isolate, " capacity" ),
2665+ CapacityGetter);
26652666 SetSideEffectFreeGetter (
26662667 isolate, tmpl, FIXED_ONE_BYTE_STRING (isolate, " db" ), DatabaseGetter);
2668+ SetSideEffectFreeGetter (isolate, tmpl, env->size_string (), SizeGetter);
26672669 return tmpl;
26682670}
26692671
@@ -2679,32 +2681,44 @@ BaseObjectPtr<SQLTagStore> SQLTagStore::Create(
26792681 return MakeBaseObject<SQLTagStore>(env, obj, std::move (database), capacity);
26802682}
26812683
2684+ void SQLTagStore::CapacityGetter (const FunctionCallbackInfo<Value>& args) {
2685+ SQLTagStore* store;
2686+ ASSIGN_OR_RETURN_UNWRAP (&store, args.This ());
2687+ args.GetReturnValue ().Set (static_cast <double >(store->sql_tags_ .Capacity ()));
2688+ }
2689+
26822690void SQLTagStore::DatabaseGetter (const FunctionCallbackInfo<Value>& args) {
26832691 SQLTagStore* store;
26842692 ASSIGN_OR_RETURN_UNWRAP (&store, args.This ());
26852693 args.GetReturnValue ().Set (store->database_ ->object ());
26862694}
26872695
2688- void SQLTagStore::Run (const FunctionCallbackInfo<Value>& info) {
2696+ void SQLTagStore::SizeGetter (const FunctionCallbackInfo<Value>& args) {
2697+ SQLTagStore* store;
2698+ ASSIGN_OR_RETURN_UNWRAP (&store, args.This ());
2699+ args.GetReturnValue ().Set (static_cast <double >(store->sql_tags_ .Size ()));
2700+ }
2701+
2702+ void SQLTagStore::Run (const FunctionCallbackInfo<Value>& args) {
26892703 SQLTagStore* session;
2690- ASSIGN_OR_RETURN_UNWRAP (&session, info .This ());
2691- Environment* env = Environment::GetCurrent (info );
2704+ ASSIGN_OR_RETURN_UNWRAP (&session, args .This ());
2705+ Environment* env = Environment::GetCurrent (args );
26922706
26932707 THROW_AND_RETURN_ON_BAD_STATE (
26942708 env, !session->database_ ->IsOpen (), " database is not open" );
26952709
2696- BaseObjectPtr<StatementSync> stmt = PrepareStatement (info );
2710+ BaseObjectPtr<StatementSync> stmt = PrepareStatement (args );
26972711
26982712 if (!stmt) {
26992713 return ;
27002714 }
27012715
2702- uint32_t n_params = info .Length () - 1 ;
2716+ uint32_t n_params = args .Length () - 1 ;
27032717 int r = sqlite3_reset (stmt->statement_ );
27042718 CHECK_ERROR_OR_THROW (env->isolate (), stmt->db_ .get (), r, SQLITE_OK, void ());
27052719 int param_count = sqlite3_bind_parameter_count (stmt->statement_ );
27062720 for (int i = 0 ; i < static_cast <int >(n_params) && i < param_count; ++i) {
2707- Local<Value> value = info [i + 1 ];
2721+ Local<Value> value = args [i + 1 ];
27082722 if (!stmt->BindValue (value, i + 1 )) {
27092723 return ;
27102724 }
@@ -2714,7 +2728,7 @@ void SQLTagStore::Run(const FunctionCallbackInfo<Value>& info) {
27142728 if (StatementExecutionHelper::Run (
27152729 env, stmt->db_ .get (), stmt->statement_ , stmt->use_big_ints_ )
27162730 .ToLocal (&result)) {
2717- info .GetReturnValue ().Set (result);
2731+ args .GetReturnValue ().Set (result);
27182732 }
27192733}
27202734
@@ -2832,23 +2846,9 @@ void SQLTagStore::All(const FunctionCallbackInfo<Value>& args) {
28322846 }
28332847}
28342848
2835- void SQLTagStore::Size (const FunctionCallbackInfo<Value>& info ) {
2849+ void SQLTagStore::Clear (const FunctionCallbackInfo<Value>& args ) {
28362850 SQLTagStore* store;
2837- ASSIGN_OR_RETURN_UNWRAP (&store, info.This ());
2838- info.GetReturnValue ().Set (
2839- Integer::New (info.GetIsolate (), store->sql_tags_ .Size ()));
2840- }
2841-
2842- void SQLTagStore::Capacity (const FunctionCallbackInfo<Value>& info) {
2843- SQLTagStore* store;
2844- ASSIGN_OR_RETURN_UNWRAP (&store, info.This ());
2845- info.GetReturnValue ().Set (
2846- Integer::New (info.GetIsolate (), store->sql_tags_ .Capacity ()));
2847- }
2848-
2849- void SQLTagStore::Clear (const FunctionCallbackInfo<Value>& info) {
2850- SQLTagStore* store;
2851- ASSIGN_OR_RETURN_UNWRAP (&store, info.This ());
2851+ ASSIGN_OR_RETURN_UNWRAP (&store, args.This ());
28522852 store->sql_tags_ .Clear ();
28532853}
28542854
0 commit comments