Skip to content

Commit eb582cd

Browse files
committed
merge latest nodejs-adapter into cluster 7.3
2 parents 63cb66d + 0a600e2 commit eb582cd

File tree

134 files changed

+5137
-2069
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+5137
-2069
lines changed

storage/ndb/nodejs/API-documentation/Batch

+348-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,334 @@
1-
Batch extends Context
1+
/** Find a specific instance based on primary or unique key value.
2+
* ASYNC
3+
*
4+
* The constructor parameter is the constructor function of a mapped domain
5+
* object.
6+
*
7+
* The parameter "keys" may be of any type. Keys must uniquely identify
8+
* a single row in the database.
9+
* If keys is a simple type (number or string), then the parameter type must
10+
* be the same type as or compatible with the primary key type of the mapped
11+
* object.
12+
* Otherwise, properties are taken from the parameter and matched against
13+
* property names in the mapping. Primary key properties will be used if all
14+
* are present, and other properties will be ignored.
15+
* If keys cannot identify the primary key, property names corresponding to
16+
* unique key columns will be used. If no complete primary or unique key
17+
* properties are found, an error is reported.
18+
*
19+
* For multi-column primary or unique keys, all key fields must be set.
20+
*
21+
* The returned object will be loaded based on the mapping and the current
22+
* values in the database.
23+
*
24+
* This function returns a promise. On success, the promise will be fulfilled
25+
* with the found object. The optional callback receives an error value and the
26+
* found object. Any extra arguments passed after the callback will
27+
* be passed to the callback function verbatim as parameters following
28+
* the found instance value.
29+
*
30+
* @method find
31+
* @param constructor the constructor function of a mapped domain object
32+
* @param keys the instance to find in the database
33+
* @param callback function to be called when operation has completed,
34+
* with parameters:
35+
* err: the node.js Error object
36+
* instance: the domain model object or null if not found
37+
* @return promise
38+
*/
39+
find(Function constructor, Object keys, [callback], [...]);
40+
41+
/** Find a specific instance based on primary or unique key value.
42+
* See other variant for semantics.
43+
* ASYNC
44+
*
45+
* @method find
46+
* @param tableName the table name
47+
* @param keys the instance to find in the database
48+
* @param callback function to be called when operation has completed,
49+
* with parameters:
50+
* err: the node.js Error object
51+
* instance: the domain model object or null if not found
52+
* @return promise
53+
*/
54+
find(String tableName, Object keys, [callback], [...]);
55+
56+
57+
/** Load a specific instance by matching its primary or unique key with
58+
* a database row. Load will never create a new domain object.
59+
* ASYNC
60+
*
61+
* The parameter "instance" must have its primary or unique key value(s) set.
62+
* The mapped values in the object will be loaded based on the current
63+
* values in the database. Unmapped properties in the object will be unchanged.
64+
*
65+
* Primary key properties will be used if all are present,
66+
* and all other properties will be ignored.
67+
* Otherwise, property names corresponding to unique key columns
68+
* will be used. If no complete primary or unique key properties
69+
* are found, an error is reported.
70+
*
71+
* This function returns a promise. On success, the promise will be fulfilled
72+
* with the loaded instance. The optional callback receives an error value and
73+
* the loaded instance. Any extra arguments passed after the callback will
74+
* be passed to the callback function verbatim as parameters following
75+
* the loaded instance value.
76+
*
77+
* @method load
78+
* @param instance the instance to load from the database
79+
* @param callback function to be called when operation has completed,
80+
* with parameters:
81+
* err: the node.js Error object
82+
* instance: the domain model object or null if not found
83+
* @return promise
84+
*/
85+
load(Object instance, [callback], [...]);
86+
87+
/** Insert the instance into the database.
88+
* ASYNC
89+
*
90+
* If the instance already exists in the database, an exception is
91+
* reported in the callback.
92+
*
93+
* For autogenerated values, the values will be present in the instance
94+
* when the callback is called.
95+
*
96+
* This function returns a promise. On success, the promise will be fulfilled.
97+
* The optional callback receives only an error value. Any extra arguments
98+
* passed after the callback will be passed to the callback function verbatim
99+
* as parameters following the error value.
100+
*
101+
* @param instance the instance to insert
102+
* @param callback function to be called when operation has completed,
103+
* with parameters:
104+
* err: the node.js Error object
105+
* @return promise
106+
*/
107+
persist(Object instance, [callback], [...]);
108+
109+
/** Insert the instance into the database. See the other variant for semantics.
110+
* ASYNC
111+
*
112+
* This function returns a promise. On success, the promise will be fulfilled.
113+
* The optional callback receives only an error value. Any extra arguments
114+
* passed after the callback will be passed to the callback function verbatim
115+
* as parameters following the error value.
116+
*
117+
* @param constructor the constructor function for a mapped domain object
118+
* @param values: values for the new instance
119+
* @param callback function to be called when operation has completed,
120+
* with parameters:
121+
* err: the node.js Error object
122+
* @return promise
123+
*/
124+
persist(Function constructor, Object values, [callback], [...]);
125+
126+
/** Insert the instance into the database. See the other variant for semantics.
127+
* ASYNC
128+
*
129+
* This function returns a promise. On success, the promise will be fulfilled.
130+
* The optional callback receives only an error value. Any extra arguments
131+
* passed after the callback will be passed to the callback function verbatim
132+
* as parameters following the error value.
133+
*
134+
* @param tableName the table name
135+
* @param values: values for the new instance
136+
* @param callback function to be called when operation has completed,
137+
* with parameters:
138+
* err: the node.js Error object
139+
* @return promise
140+
*/
141+
persist(String tableName, Object values, [callback]. [...]);
142+
143+
/** Delete an instance of a class from the database by a primary or unique key.
144+
* ASYNC
145+
* The key values in the object must uniquely identify
146+
* a single row in the database.
147+
* If the instance does not exist in the database,
148+
* an error is reported in the callback.
149+
*
150+
* This function returns a promise. On success, the promise will be fulfilled.
151+
* The optional callback receives only an error value. Any extra arguments
152+
* passed after the callback will be passed to the callback function verbatim
153+
* as parameters following the error value.
154+
*
155+
* @param the instance of a mapped domain object to delete from the database
156+
* @param callback function to be called when operation has completed,
157+
* with parameters:
158+
* err: the node.js Error object
159+
* @return promise
160+
*/
161+
remove(Object instance, [callback], [...]);
162+
163+
/** Delete a row from the database by a unique or primary key.
164+
* ASYNC
165+
* The constructor parameter is the constructor function for a mapped domain
166+
* object. If keys is a simple type (number or string), then the parameter type
167+
* must be the same type as or compatible with the primary key type
168+
* of the mapped object.
169+
* Otherwise, properties are taken from the parameter and matched against
170+
* property names in the mapping.
171+
* If all Primary Key properties are present, they will be used,
172+
* and other properties will be ignored.
173+
* Otherwise, if keys cannot identify the primary key, property names
174+
* corresponding to unique key columns will be used.
175+
* If no complete primary or unique key properties are found, an error
176+
* is reported.
177+
*
178+
* This function returns a promise. On success, the promise will be fulfilled.
179+
* The optional callback receives only an error value. Any extra arguments
180+
* passed after the callback will be passed to the callback function verbatim
181+
* as parameters following the error value.
182+
*
183+
* @param constructor the constructor for a mapped domain object
184+
* @param keys object containing the keys of the object to delete
185+
* @param callback function to be called when operation has completed, with parameters:
186+
* err: the node.js Error object
187+
* @return promise
188+
*/
189+
remove(Function constructor, Object keys, [callback], [...]);
190+
191+
/** Delete a row from the database by a unique or primary key.
192+
* ASYNC
193+
* See other variant for semantics.
194+
*
195+
* This function returns a promise. On success, the promise will be fulfilled.
196+
* The optional callback receives only an error value. Any extra arguments
197+
* passed after the callback will be passed to the callback function verbatim
198+
* as parameters following the error value.
199+
*
200+
* @param tableName the table name
201+
* @param keys object containing the keys of the object to delete
202+
* @param callback function to be called when operation has completed,
203+
* with parameters:
204+
* err: the node.js Error object
205+
* @return promise
206+
*/
207+
remove(String tableName, Object keys, [callback], [...]);
208+
209+
/** Update the instance in the database without necessarily retrieving it.
210+
* The primary key field is used to determine which instance is to be updated.
211+
* If the instance does not exist in the database, an error is reported.
212+
* This method cannot be used to change the primary key.
213+
*
214+
* This function returns a promise. On success, the promise will be fulfilled.
215+
* The optional callback receives only an error value. Any extra arguments
216+
* passed after the callback will be passed to the callback function verbatim
217+
* as parameters following the error value.
218+
*
219+
* @param instance the instance to update
220+
* @param callback function to be called when operation has completed,
221+
* with parameters:
222+
* err: the node.js Error object
223+
* @return promise
224+
* ASYNC
225+
*/
226+
update(Object instance, [callback], [...]);
227+
228+
/** Update the instance in the database without necessarily retrieving it.
229+
* Unique key field(s) of the keys object determine which instance
230+
* is to be updated. The values object provides values to be updated.
231+
* If the keys object contains all fields corresponding to the primary key,
232+
* the primary key will identify the instance. If not, unique keys will be
233+
* chosen non-deterministically.
234+
* If the instance does not exist in the database, an error is reported.
235+
* This method cannot be used to change the primary key.
236+
*
237+
* This function returns a promise. On success, the promise will be fulfilled.
238+
* The optional callback receives only an error value. Any extra arguments
239+
* passed after the callback will be passed to the callback function verbatim
240+
* as parameters following the error value.
241+
*
242+
* @param constructor constructor function of a mapped domain object
243+
* @param keys an object containing unique keys for the instance to update
244+
* @param values an object containing values to update
245+
* @param callback function to be called when operation has completed,
246+
* with parameters:
247+
* err: the node.js Error object
248+
* @return promise
249+
* ASYNC
250+
*/
251+
update(Function constructor, keys, values, [callback], [...]);
252+
253+
/** Update the instance in the database without necessarily retrieving it.
254+
* See other variant for semantics.
255+
*
256+
* This function returns a promise. On success, the promise will be fulfilled.
257+
* The optional callback receives only an error value. Any extra arguments
258+
* passed after the callback will be passed to the callback function verbatim
259+
* as parameters following the error value.
260+
*
261+
* @param tableName the table name
262+
* @param keys an object containing unique keys for the instance to update
263+
* @param values an object containing values to update
264+
* @param callback function to be called when operation has completed,
265+
* with parameters:
266+
* err: the node.js Error object
267+
* @return promise
268+
* ASYNC
269+
*/
270+
update(String tableName, keys, values, [callback], [...]);
271+
272+
/** Save the instance in the database without checking for existence.
273+
* The id field is used to determine which instance is to be saved.
274+
* If the instance exists in the database it will be updated.
275+
* If the instance does not exist, it will be created.
276+
*
277+
* This function returns a promise. On success, the promise will be fulfilled.
278+
* The optional callback receives only an error value. Any extra arguments
279+
* passed after the callback will be passed to the callback function verbatim
280+
* as parameters following the error value.
281+
*
282+
* @param instance the instance to insert or update
283+
* @param callback function to be called when operation has completed,
284+
* with parameters:
285+
* err: the node.js Error object
286+
* @return promise
287+
* ASYNC
288+
*/
289+
save(Object instance, [callback], [...]);
290+
291+
/** Save the instance in the database without checking for existence.
292+
* See other variant for semantics.
293+
*
294+
* This function returns a promise. On success, the promise will be fulfilled.
295+
* The optional callback receives only an error value. Any extra arguments
296+
* passed after the callback will be passed to the callback function verbatim
297+
* as parameters following the error value.
298+
*
299+
* @param constructor the constructor function of a mapped domain object
300+
* @param values the values to insert or update
301+
* @param callback function to be called when operation has completed,
302+
* with parameters:
303+
* err: the node.js Error object
304+
* @return promise
305+
* ASYNC
306+
*/
307+
save(Function constructor, Object values, [callback], [...]);
308+
309+
/** Save the instance in the database without checking for existence.
310+
* See other variant for semantics.
311+
*
312+
* This function returns a promise. On success, the promise will be fulfilled.
313+
* The optional callback receives only an error value. Any extra arguments
314+
* passed after the callback will be passed to the callback function verbatim
315+
* as parameters following the error value.
316+
*
317+
* @param tableName the name of the table
318+
* @param values the values to insert or update
319+
* @param callback function to be called when operation has completed,
320+
* with parameters:
321+
* err: the node.js Error object
322+
* @return promise
323+
* ASYNC
324+
*/
325+
save(String tableName, Object values, [callback], [...]);
326+
327+
/** Is this context a batch?
328+
* @return true if this context is a batch; false if this context is a session
329+
* IMMEDIATE
330+
*/
331+
isBatch();
2332

3333
/** execute()
4334
* ASYNC
@@ -7,11 +337,17 @@ Batch extends Context
7337
* The execute function's callback is also called.
8338
* The batch is executed in the context of the session's current state:
9339
* autocommit if a transaction has not been started;
10-
* default lock mode;
11-
* the partition key.
12-
* @return undefined
340+
*
341+
* execute() returns a promise. On success, the promise will be fulfilled.
342+
* The optional callback receives only an error value and any extra arguments.
343+
* Extra arguments passed after the callback will be passed to the callback
344+
* function verbatim as parameters following the error.
345+
*
346+
* @method execute
347+
* @param callback
348+
* @return promise
13349
*/
14-
execute(Function(error, ... ) callback, ...);
350+
execute([callback], [...]);
15351

16352
/** clear()
17353
* IMMEDIATE
@@ -29,3 +365,10 @@ clear();
29365
* @return the session
30366
*/
31367
getSession();
368+
369+
370+
/*
371+
* Users may find useful a "user" property of session and batch.
372+
* The mynode implementation will not ever define a property called "user".
373+
*/
374+

0 commit comments

Comments
 (0)