Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
@c This file is a part of the CaosDB Project.
@c
@c Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
@c Copyright (C) 2021 Daniel Hornung <d.hornung@indiscale.com>
@c
@c This program is free software: you can redistribute it and/or modify
@c it under the terms of the GNU Affero General Public License as
@c published by the Free Software Foundation, either version 3 of the
@c License, or (at your option) any later version.
@c
@c This program is distributed in the hope that it will be useful,
@c but WITHOUT ANY WARRANTY; without even the implied warranty of
@c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@c GNU Affero General Public License for more details.
@c
@c You should have received a copy of the GNU Affero General Public License
@c along with this program. If not, see <https://www.gnu.org/licenses/>.
@node Caosdb
@comment node-name, next, previous, up
@chapter The CaosDB class
@c %%%%%%%%%%%%%%% Caosdb %%%%%%%%%%%%%%%
@deftp {Class} Caosdb
This is the main class of the CaosDB client for Octave.
The @code{Caosdb} class holds information about the connection to a CaosDB server. It provides a
convenient interface to the possible transactions (insert, query, retrieve, update, delete) with the
server.
@end deftp
@c %%%%%%%%%%%%%%% connection %%%%%%%%%%%%%%%
@deftypeivar {Caosdb} string connection
The name of the connection which shall be used for transactions via this @code{Caosdb} object. The
available connections are taken from the active libcaosdb configuration. If @code{connection} is
the empty string, the default connection will be used.
@end deftypeivar
@c %%%%%%%%%%%%%%% Caosdb() %%%%%%%%%%%%%%%
@defmethod Caosdb Caosdb ([string @var{connection}])
The constructor takes an optional @var{connection} argument which, if given, is used as connection
name for transactions via this object.
@end defmethod
@c %%%%%%%%%%%%%%% info() %%%%%%%%%%%%%%%
@defmethod Caosdb info ()
Return a string with information about the libraries and the server.
@end defmethod
@c %%%%%%%%%%%%%%% retrieve_by_id() %%%%%%%%%%%%%%%
@defmethod Caosdb retrieve_by_id( @var{ids}, @dots{} )
Retrieve entities by IDs.
@example
entities = Caosdb.retrieve_by_id("my_id", @{"more", "ids"@});
@end example
@strong{Parameters}
@param{ids, string or cell array of strings, The ID(s) of the entity (entities) to be retrieved.}
@strong{Returns}
@param{entities, cell array, The retrieved entities.}
@end defmethod
@c %%%%%%%%%%%%%%% query() %%%%%%%%%%%%%%%
@defmethod Caosdb query( @var{query_str} )
Execute a query.
@example
entities = Caosdb.query("FIND Record Foo WITH bar=baz");
entities = Caosdb.query("COUNT Record Foo WITH bar=baz");
@end example
@strong{Parameters}
@param{query_str, string, The query to be executed.}
@strong{Returns}
@param{entities, cell array, The retrieved entities. If the query was a COUNT query@comma{} the
result is an int64 instead.}
@end defmethod
@c %%%%%%%%%%%%%%% insert() %%%%%%%%%%%%%%%
@defmethod Caosdb insert( @var{entities} )
Insert an entity.
@example
inserted = Caosdb.insert(entities);
@end example
@strong{Parameters}
@param{entities, cell array, A cell array with the entities to be inserted.}
@strong{Returns}
@param{inserted, cell array, The resulting inserted entities (sparse@comma{} only for ID and
version).}
@end defmethod
@c %%%%%%%%%%%%%%% update() %%%%%%%%%%%%%%%
@defmethod Caosdb update( @var{entities} )
Update an entity.
@example
updated = Caosdb.update(entities);
@end example
@strong{Parameters}
@param{entities, cell array, A cell array with the entities to be updated. All entities must have a
valid ID.}
@strong{Returns}
@param{updated, cell array, The resulting updated entities.}
@end defmethod
@c %%%%%%%%%%%%%%% delete_by_id() %%%%%%%%%%%%%%%
@defmethod Caosdb retrieve_by_id( @var{ids}, @dots{} )
Delete entities by IDs.
@example
entities = Caosdb.delete_by_id("my_id", @{"more", "ids"@});
@end example
The usage is equivalent to @code{retrieve_by_id(...)}.
@cartouche
@b{Note:} @code{Caosdb.delete()} will call the destructor of the Caosdb object.
@end cartouche
@strong{Parameters}
@param{ids, string or cell array of strings, The ID(s) of the entity (entities) to be deleted.}
@strong{Returns}
@param{entities, cell array, The deleted entities.}
@end defmethod
@c %%%%%%%%%%%%%%% download_file_by_single_id() %%%%%%%%%%%%%%%
@defmethod Caosdb download_file_by_single_id( @var{id}, @var{local_path} )
Download a file by ID.
@example
entity = Caosdb.download_file_by_single_id("my_id", "/save/file/here.dat");
@end example
Inserting files is done by creating a "@code{FILE}" @ref{Entity} and inserting it.
@strong{Parameters}
@param{ids, string, The ID of the file to be downloaded.}
@param{local_path, string, The location where the file shall be saved.}
@strong{Returns}
@param{entity, cell array, 1x1 cell array with the retrieved file entity.}
@end defmethod