GenericResult
Direct Subclass:
Member Summary
Public Members | ||
public |
[_a](onfinally: function() | null): Promise Called when finally the result is done |
Method Summary
Public Methods | ||
public |
[Symbol.asyncIterator](): PeekableAsyncIterator<R, ResultSummary> Provides a async iterator over the records in the result. |
|
public |
as(constructorOrRules: GenericConstructor<T> | Rules, rules: Rules): MappedResult<T> Maps the records of this result to a provided type and/or according to provided Rules. |
|
public |
catch(onRejected: function(error: Neo4jError)): Promise Catch errors when using promises. |
|
public |
finally() |
|
public |
isOpen(): boolean Check if this result is active, i.e., neither a summary nor an error has been received by the result. |
|
public |
keys(): Promise<string[]> Returns a promise for the field keys. |
|
public |
subscribe(observer: Object): void Stream records to observer as they come in, this is a more efficient method of handling the results, and allows you to handle arbitrarily large results. |
|
public |
summary(): Promise<ResultSummary<T>> Returns a promise for the result summary. |
|
public |
then(onFulfilled: function(result: {records: Array<Record>, summary: ResultSummary}), onRejected: function(error: {message: string, code: string})): Promise Waits for all results and calls the passed in function with the results. |
Public Members
public [_a](onfinally: function() | null): Promise source
Called when finally the result is done
Should not be combined with Result#subscribe function.
Return:
Promise | promise. |
Public Methods
public [Symbol.asyncIterator](): PeekableAsyncIterator<R, ResultSummary> source
Provides a async iterator over the records in the result.
Should not be combined with Result#subscribe or Result#then functions.
public as(constructorOrRules: GenericConstructor<T> | Rules, rules: Rules): MappedResult<T> source
Maps the records of this result to a provided type and/or according to provided Rules.
NOTE: This modifies the Result object itself, and can not be run on a Result that is already being consumed.
Params:
Name | Type | Attribute | Description |
constructorOrRules | GenericConstructor<T> | Rules | ||
rules | Rules |
Return:
MappedResult<T> |
Example:
class Person {
constructor (
public readonly name: string,
public readonly born?: number
) {}
}
const personRules: Rules = {
name: rule.asString(),
born: rule.asNumber({ acceptBigInt: true, optional: true })
}
await session.executeRead(async (tx: Transaction) => {
let txres = tx.run(`MATCH (p:Person)-[r:ACTED_IN]->(m:Movie)<-[:ACTED_IN]-(c:Person)
WHERE id(p) <> id(c)
RETURN p.name as name, p.born as born`).as<Person>(personRules)
public catch(onRejected: function(error: Neo4jError)): Promise source
Catch errors when using promises.
Should not be combined with Result#subscribe function.
Params:
Name | Type | Attribute | Description |
onRejected | function(error: Neo4jError) | Function to be called upon errors. |
Return:
Promise | promise. |
public finally() source
public isOpen(): boolean source
Check if this result is active, i.e., neither a summary nor an error has been received by the result.
Return:
boolean |
|
public keys(): Promise<string[]> source
Returns a promise for the field keys.
Should not be combined with Result#subscribe function.
Return:
Promise<string[]> | Field keys, in the order they will appear in records. } |
public subscribe(observer: Object): void source
Stream records to observer as they come in, this is a more efficient method of handling the results, and allows you to handle arbitrarily large results.
Params:
Name | Type | Attribute | Description |
observer | Object | Observer object |
|
observer.onKeys | function(keys: string[]) | handle stream head, the field keys. |
|
observer.onNext | function(record: Record) | handle records, one by one. |
|
observer.onCompleted | function(summary: ResultSummary) | handle stream tail, the result summary. |
|
observer.onError | function(error: {message: string, code: string}) | handle errors. |
Return:
void |
public summary(): Promise<ResultSummary<T>> source
Returns a promise for the result summary.
Should not be combined with Result#subscribe function.
public then(onFulfilled: function(result: {records: Array<Record>, summary: ResultSummary}), onRejected: function(error: {message: string, code: string})): Promise source
Waits for all results and calls the passed in function with the results.
Should not be combined with Result#subscribe function.
Params:
Name | Type | Attribute | Description |
onFulfilled | function(result: {records: Array<Record>, summary: ResultSummary}) | function to be called when finished. |
|
onRejected | function(error: {message: string, code: string}) | function to be called upon errors. |
Return:
Promise | promise. |