MCPcopy Create free account
hub / github.com/WiseLibs/better-sqlite3 / Statement

Class Statement

src/objects/statement.hpp:1–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Statement : public Napi::ObjectWrap<Statement> { friend class StatementIterator;
2public:
3
4 explicit Statement(const Napi::CallbackInfo& info);
5 ~Statement();
6
7 // Whenever this is used, db->RemoveStatement must be invoked beforehand.
8 void CloseHandles();
9
10 // Used to support ordered containers.
11 static inline bool Compare(Statement const * const a, Statement const * const b) {
12 return a->extras->id < b->extras->id;
13 }
14
15 // Returns the Statement's bind map (creates it upon first execution).
16 BindMap& GetBindMap(Napi::Env env);
17
18 // Returns the Statement's row builder.
19 RowBuilder& GetRowBuilder();
20
21 // Identifies objects that are backed by this class (see IsInstanceOf).
22 static const napi_type_tag TYPE_TAG;
23
24 static INIT(Init);
25
26private:
27
28 // A class for holding values that are less often used.
29 class Extras { friend class Statement; friend class StatementIterator;
30 explicit Extras(
31 Napi::Env env,
32 Napi::Function row_factory,
33 Napi::Function array_Factory,
34 sqlite3_uint64 id
35 );
36 BindMap bind_map;
37 RowBuilder row_builder;
38 const sqlite3_uint64 id;
39 };
40
41 NODE_METHOD(JS_new);
42 static NODE_METHOD(JS_run);
43 static NODE_METHOD(JS_get);
44 static NODE_METHOD(JS_all);
45 static NODE_METHOD(JS_iterate);
46 static NODE_METHOD(JS_bind);
47 static NODE_METHOD(JS_pluck);
48 static NODE_METHOD(JS_expand);
49 static NODE_METHOD(JS_raw);
50 static NODE_METHOD(JS_safeIntegers);
51 static NODE_METHOD(JS_columns);
52 static NODE_METHOD(JS_toString);
53 static NODE_GETTER(JS_busy);
54
55 Database* db;
56 sqlite3_stmt* handle;
57 Extras* extras;
58 bool alive;
59 bool locked;
60 bool bound;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected