@@ -2700,11 +2700,13 @@ Local<FunctionTemplate> SQLTagStore::GetConstructorTemplate(Environment* env) {
27002700 SetProtoMethod (isolate, tmpl, " iterate" , Iterate);
27012701 SetProtoMethod (isolate, tmpl, " run" , Run);
27022702 SetProtoMethod (isolate, tmpl, " clear" , Clear);
2703- SetProtoMethod (isolate, tmpl, " size" , Size);
2704- SetSideEffectFreeGetter (
2705- isolate, tmpl, FIXED_ONE_BYTE_STRING (isolate, " capacity" ), Capacity);
2703+ SetSideEffectFreeGetter (isolate,
2704+ tmpl,
2705+ FIXED_ONE_BYTE_STRING (isolate, " capacity" ),
2706+ CapacityGetter);
27062707 SetSideEffectFreeGetter (
27072708 isolate, tmpl, FIXED_ONE_BYTE_STRING (isolate, " db" ), DatabaseGetter);
2709+ SetSideEffectFreeGetter (isolate, tmpl, env->size_string (), SizeGetter);
27082710 return tmpl;
27092711}
27102712
@@ -2720,32 +2722,44 @@ BaseObjectPtr<SQLTagStore> SQLTagStore::Create(
27202722 return MakeBaseObject<SQLTagStore>(env, obj, std::move (database), capacity);
27212723}
27222724
2725+ void SQLTagStore::CapacityGetter (const FunctionCallbackInfo<Value>& args) {
2726+ SQLTagStore* store;
2727+ ASSIGN_OR_RETURN_UNWRAP (&store, args.This ());
2728+ args.GetReturnValue ().Set (static_cast <double >(store->sql_tags_ .Capacity ()));
2729+ }
2730+
27232731void SQLTagStore::DatabaseGetter (const FunctionCallbackInfo<Value>& args) {
27242732 SQLTagStore* store;
27252733 ASSIGN_OR_RETURN_UNWRAP (&store, args.This ());
27262734 args.GetReturnValue ().Set (store->database_ ->object ());
27272735}
27282736
2729- void SQLTagStore::Run (const FunctionCallbackInfo<Value>& info) {
2737+ void SQLTagStore::SizeGetter (const FunctionCallbackInfo<Value>& args) {
2738+ SQLTagStore* store;
2739+ ASSIGN_OR_RETURN_UNWRAP (&store, args.This ());
2740+ args.GetReturnValue ().Set (static_cast <double >(store->sql_tags_ .Size ()));
2741+ }
2742+
2743+ void SQLTagStore::Run (const FunctionCallbackInfo<Value>& args) {
27302744 SQLTagStore* session;
2731- ASSIGN_OR_RETURN_UNWRAP (&session, info .This ());
2732- Environment* env = Environment::GetCurrent (info );
2745+ ASSIGN_OR_RETURN_UNWRAP (&session, args .This ());
2746+ Environment* env = Environment::GetCurrent (args );
27332747
27342748 THROW_AND_RETURN_ON_BAD_STATE (
27352749 env, !session->database_ ->IsOpen (), " database is not open" );
27362750
2737- BaseObjectPtr<StatementSync> stmt = PrepareStatement (info );
2751+ BaseObjectPtr<StatementSync> stmt = PrepareStatement (args );
27382752
27392753 if (!stmt) {
27402754 return ;
27412755 }
27422756
2743- uint32_t n_params = info .Length () - 1 ;
2757+ uint32_t n_params = args .Length () - 1 ;
27442758 int r = sqlite3_reset (stmt->statement_ );
27452759 CHECK_ERROR_OR_THROW (env->isolate (), stmt->db_ .get (), r, SQLITE_OK, void ());
27462760 int param_count = sqlite3_bind_parameter_count (stmt->statement_ );
27472761 for (int i = 0 ; i < static_cast <int >(n_params) && i < param_count; ++i) {
2748- Local<Value> value = info [i + 1 ];
2762+ Local<Value> value = args [i + 1 ];
27492763 if (!stmt->BindValue (value, i + 1 )) {
27502764 return ;
27512765 }
@@ -2755,7 +2769,7 @@ void SQLTagStore::Run(const FunctionCallbackInfo<Value>& info) {
27552769 if (StatementExecutionHelper::Run (
27562770 env, stmt->db_ .get (), stmt->statement_ , stmt->use_big_ints_ )
27572771 .ToLocal (&result)) {
2758- info .GetReturnValue ().Set (result);
2772+ args .GetReturnValue ().Set (result);
27592773 }
27602774}
27612775
@@ -2873,23 +2887,9 @@ void SQLTagStore::All(const FunctionCallbackInfo<Value>& args) {
28732887 }
28742888}
28752889
2876- void SQLTagStore::Size (const FunctionCallbackInfo<Value>& info ) {
2890+ void SQLTagStore::Clear (const FunctionCallbackInfo<Value>& args ) {
28772891 SQLTagStore* store;
2878- ASSIGN_OR_RETURN_UNWRAP (&store, info.This ());
2879- info.GetReturnValue ().Set (
2880- Integer::New (info.GetIsolate (), store->sql_tags_ .Size ()));
2881- }
2882-
2883- void SQLTagStore::Capacity (const FunctionCallbackInfo<Value>& info) {
2884- SQLTagStore* store;
2885- ASSIGN_OR_RETURN_UNWRAP (&store, info.This ());
2886- info.GetReturnValue ().Set (
2887- Integer::New (info.GetIsolate (), store->sql_tags_ .Capacity ()));
2888- }
2889-
2890- void SQLTagStore::Clear (const FunctionCallbackInfo<Value>& info) {
2891- SQLTagStore* store;
2892- ASSIGN_OR_RETURN_UNWRAP (&store, info.This ());
2892+ ASSIGN_OR_RETURN_UNWRAP (&store, args.This ());
28932893 store->sql_tags_ .Clear ();
28942894}
28952895
0 commit comments