$darkmode

| Qore DbDataProvider Module Reference 2.0.1

DbDataProvider.qc.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
26 namespace DbDataProvider {
28 class DbDataProvider : public AbstractDataProvider {
29
30 public:
32 const ProviderInfo = <DataProviderInfo>{
33 "type": "DbDataProvider",
34 "supports_read": True,
35 "supports_bulk_read": True,
36 "supports_children": True,
37 "constructor_options": ConstructorOptions,
38 "search_options": SearchOptions,
39 "create_options": NOTHING,
40 "upsert_options": NOTHING,
41 "child_create_options": ChildCreateOptions,
42 "transaction_management": True,
43 "has_record": True,
44 "record_requires_search_options": True,
45 "supports_child_create": True,
46 "supports_child_delete": True,
47 "children_can_support_apis": False,
48 "children_can_support_records": True,
49 "children_can_support_observers": False,
50 };
51
53 const ConstructorOptions = {
54 "datasource": <DataProviderOptionInfo>{
55 "type": (
56 AbstractDataProviderType::get(StringType),
57 AbstractDataProviderType::get(new Type("AbstractDatasource")),
58 ),
59 "desc": "the datasource connection string or an abstract datasource object",
60 "required": True,
61 },
62 };
63
65 const SearchOptions = {
66 "sql": <DataProviderOptionInfo>{
67 "type": AbstractDataProviderType::get(StringType),
68 "desc": "the raw SQL for the select statement",
69 "required": True,
70 },
71 "args": <DataProviderOptionInfo>{
72 "type": AbstractDataProviderType::get(AutoListType),
73 "desc": "any bind arguments for the select statement",
74 },
75 };
76
78 const ChildCreateOptions = {
79 "primary_key": <DataProviderOptionInfo>{
80 "type": AbstractDataProviderType::get("softlist<string>"),
81 "desc": "a list of column names for the primary key for the table; use `primary_key_name` to set the "
82 "name of the primary key constraint manually, otherwise a suitable name will be automatically "
83 "generated",
84 },
85 "primary_key_name": <DataProviderOptionInfo>{
86 "type": AbstractDataProviderType::get(StringType),
87 "desc": "the name of the primary key constraint; only used if `primary_key` is set",
88 },
89 "indexes": <DataProviderOptionInfo>{
90 "type": new DbIndexesDataType(),
91 "desc": "a hash of indexes keyed by index name",
92 },
93 "foreign_constraints": <DataProviderOptionInfo>{
94 "type": new DbForeignConstraintsDataType(),
95 "desc": "a hash of foreign constraints keyed by foreign constraint name",
96 },
97 };
98
99 protected:
101 AbstractDatabase db;
102
104 static *code datasource_lookup;
105
107 static *code table_lookup;
108
109 public:
110
112 constructor(AbstractDatasource ds, *hash<auto> opts);
113
114
116 constructor(AbstractDatabase db);
117
118
120 constructor(*hash<auto> options);
121
122
124 string getName();
125
126
128 *string getDesc();
129
130
132
139 beginTransaction();
140
141
143
148 commit();
149
150
152
157 rollback();
158
159
161
166 static *hash<string, AbstractDataField> getRecordTypeFromDescribeHash(hash<auto> describe_hash);
167
169
173 protected:
174 *hash<string, AbstractDataField> getRecordTypeImpl(*hash<auto> search_options);
175 public:
176
177
179
186 private AbstractDataProviderBulkRecordInterface searchRecordsBulkImpl(int block_size = 1000,
187 *hash<auto> where_cond, *hash<auto> search_options) {
188 return new DbSelectBulkRecordInterface(block_size, db.getDatasource(), where_cond, search_options);
189 }
190
192
197 protected:
198 AbstractDataProviderRecordIterator searchRecordsImpl(*hash<auto> where_cond, *hash<auto> search_options);
199 public:
200
201
203 *list<hash<DataProviderSummaryInfo>> getChildProviderSummaryInfo();
204
205
207
209 protected:
210 *list<string> getChildProviderNamesImpl();
211 public:
212
213
215
221 protected:
222 *AbstractDataProvider getChildProviderImpl(string name);
223 public:
224
225
227 protected:
228 hash<DataProviderInfo> getStaticInfoImpl();
229 public:
230
231
233
241 private AbstractDataProvider createChildProviderImpl(string name, hash<string, AbstractDataField> fields,
242 *hash<auto> child_create_options) {
243 hash<auto> table_desc = makeTableDesc(name, fields, child_create_options);
244 AbstractTable table = db.makeTable(name, table_desc);
245 DbTableTransactionHelper th(table);
246 th.create();
247 if (logger);
248
249 return new DbTableDataProvider(table, logger);
250 }
251
253
260 protected:
261 deleteChildProviderImpl(string name, *hash<auto> child_delete_options);
262 public:
263
264
266 static setDatasourceLookup(code datasource_lookup);
267
269 static setTableLookup(code table_lookup);
270
272 static AbstractDatasource getDatasource(AbstractDatasource ds);
273
275 static AbstractDatasource getDatasource(string ds_string);
276
278 static AbstractTable getTable(string ds_string, string table_string);
279
281 static AbstractTable getTable(AbstractDatasource ds, string table_string);
282
284 static hash<GenericColumnInfo> getColumnDesc(AbstractDatabase db, AbstractDataField field, *hash<auto> opts);
285
287
289 hash<auto> makeTableDesc(string name, hash<string, AbstractDataField> fields, *hash<auto> opts);
290
291};
292};
DbDataProvider::DbDataProvider::datasource_lookup
static *code datasource_lookup
Lookup to get an abstract datasource from a name.
Definition: DbDataProvider.qc.dox.h:104
DbDataProvider::DbDataProvider::getTable
static AbstractTable getTable(string ds_string, string table_string)
Returns an AbstractTable object from the given datasource and table strings.
DbDataProvider::DbDataProvider::beginTransaction
beginTransaction()
Begins a transaction in the datasource.
DbDataProvider::DbDataProvider::commit
commit()
Commits any transaction in progress in the datasource.
DbDataProvider::DbDataProvider::getRecordTypeFromDescribeHash
static *hash< string, AbstractDataField > getRecordTypeFromDescribeHash(hash< auto > describe_hash)
Returns the record type description from a describe hash.
DbDataProvider::DbDataProvider::getDesc
*string getDesc()
Returns the data provider description.
DbDataProvider::DbDataProvider::searchRecordsImpl
AbstractDataProviderRecordIterator searchRecordsImpl(*hash< auto > where_cond, *hash< auto > search_options)
Returns an iterator for zero or more records matching the search options.
DbDataProvider::DbDataProvider::db
AbstractDatabase db
The database object.
Definition: DbDataProvider.qc.dox.h:101
DbDataProvider::DbDataProvider::getTable
static AbstractTable getTable(AbstractDatasource ds, string table_string)
Returns an AbstractTable object from the given datasource and table arguments.
DbDataProvider::DbDataProvider::createChildProviderImpl
private AbstractDataProvider createChildProviderImpl(string name, hash< string, AbstractDataField > fields, *hash< auto > child_create_options)
Creates a new child data provider and returns it after adding as a child.
Definition: DbDataProvider.qc.dox.h:241
DbDataProvider::DbDataProvider::getColumnDesc
static hash< GenericColumnInfo > getColumnDesc(AbstractDatabase db, AbstractDataField field, *hash< auto > opts)
Returns a column description hash for a field.
DbDataProvider::DbDataProvider::setDatasourceLookup
static setDatasourceLookup(code datasource_lookup)
Sets the datasource lookup.
DbDataProvider::DbDataProvider::getDatasource
static AbstractDatasource getDatasource(AbstractDatasource ds)
Returns the given AbstractDatasource object.
DbDataProvider::DbDataProvider::deleteChildProviderImpl
deleteChildProviderImpl(string name, *hash< auto > child_delete_options)
Deletes a child data provider.
DbDataProvider::DbDataProvider::getChildProviderImpl
*AbstractDataProvider getChildProviderImpl(string name)
Returns the given child provider or NOTHING if the given child is unknown.
DbDataProvider::DbDataProvider::searchRecordsBulkImpl
private AbstractDataProviderBulkRecordInterface searchRecordsBulkImpl(int block_size=1000, *hash< auto > where_cond, *hash< auto > search_options)
Returns an iterator for zero or more records matching the search options.
Definition: DbDataProvider.qc.dox.h:186
DbDataProvider::DbDataProvider::constructor
constructor(AbstractDatasource ds, *hash< auto > opts)
creates the object
DbDataProvider::DbDataProvider::getChildProviderNamesImpl
*list< string > getChildProviderNamesImpl()
Returns a list of child data provider names, if any.
DbDataProvider::DbDataProvider::makeTableDesc
hash< auto > makeTableDesc(string name, hash< string, AbstractDataField > fields, *hash< auto > opts)
Returns a table description hash from a field description.
DbDataProvider::DbDataProvider::getDatasource
static AbstractDatasource getDatasource(string ds_string)
Returns an AbstractDatasource object from the given string.
DbDataProvider::DbDataProvider::getName
string getName()
Returns the data provider name.
DbDataProvider::DbDataProvider::table_lookup
static *code table_lookup
Lookup to get an abstract table from a datasource and a name.
Definition: DbDataProvider.qc.dox.h:107
DbDataProvider::DbDataProvider::constructor
constructor(AbstractDatabase db)
creates the object
DbDataProvider::DbDataProvider::getRecordTypeImpl
*hash< string, AbstractDataField > getRecordTypeImpl(*hash< auto > search_options)
Returns the description of the record type, if any.
DbDataProvider::DbDataProvider::setTableLookup
static setTableLookup(code table_lookup)
Sets the table lookup.
DbDataProvider::DbDataProvider::getStaticInfoImpl
hash< DataProviderInfo > getStaticInfoImpl()
Returns data provider static info.
DbDataProvider::DbDataProvider::getChildProviderSummaryInfo
*list< hash< DataProviderSummaryInfo > > getChildProviderSummaryInfo()
Return data provider summary info.
DbDataProvider::DbDataProvider::constructor
constructor(*hash< auto > options)
Creates the object from constructor options.
DbDataProvider::DbDataProvider::rollback
rollback()
Rolls back any transaction in progress in the datasource.
DbDataProvider::DbForeignConstraintsDataType
The type definition for foreign constraints.
Definition: DbForeignConstraintsDataType.qc.dox.h:4
DbDataProvider::DbIndexesDataType
The type definition for DB indexes.
Definition: DbIndexesDataType.qc.dox.h:4
DbDataProvider::DbSelectBulkRecordInterface
Defines the record iterator class for Table-based iterators.
Definition: DbSelectBulkRecordInterface.qc.dox.h:28
DbDataProvider::DbTableDataProvider
Defines a data provider based on a single SQL table.
Definition: DbTableDataProvider.qc.dox.h:28
True
const True
False
const False
NOTHING
const NOTHING
DbDataProvider
Qore AbstractDbRecordIterator class definition.
Definition: AbstractDbRecordIterator.qc.dox.h:26