Build a Query object.
**Queries are built with {module:datastore#createQuery} and .**
[Datastore Queries] http://goo.gl/Cag0r6
Package
@google-cloud/datastore!Constructors
(constructor)(scope, kinds)
constructor
(
scope
?:
Datastore
|
Transaction
,
kinds
?:
string
[]
|
null
);
Constructs a new instance of the Query
class
Type | Name | Description |
---|---|---|
Datastore
| Transaction
|
scope | |
string[] | null
|
kinds |
(constructor)(scope, namespace, kinds)
constructor
(
scope
?:
Datastore
|
Transaction
,
namespace
?:
string
|
null
,
kinds
?:
string
[]);
Constructs a new instance of the Query
class
Type | Name | Description |
---|---|---|
Datastore
| Transaction
|
scope | |
string | null
|
namespace | |
string[]
|
kinds |
Properties
endVal
endVal
:
string
|
Buffer
|
null
;
Type | Description |
---|---|
string | Buffer | null |
filters
filters
:
Filter
[];
Type | Description |
---|---|
Filter [] |
groupByVal
groupByVal
:
Array
< {}>;
Type | Description |
---|---|
Array <{}> |
kinds
kinds
:
string
[];
Type | Description |
---|---|
string[] |
limitVal
limitVal
:
number
;
Type | Description |
---|---|
number |
namespace
namespace
?:
string
|
null
;
Type | Description |
---|---|
string | null |
offsetVal
offsetVal
:
number
;
Type | Description |
---|---|
number |
orders
orders
:
Order
[];
Type | Description |
---|---|
Order [] |
scope
scope
?:
Datastore
|
Transaction
;
Type | Description |
---|---|
Datastore | Transaction |
selectVal
selectVal
:
Array
< {}>;
Type | Description |
---|---|
Array <{}> |
startVal
startVal
:
string
|
Buffer
|
null
;
Type | Description |
---|---|
string | Buffer | null |
Methods
end(end)
end
(
end
:
string
|
Buffer
)
:
this
;
Set an ending cursor to a query.
[Query Cursors] https://cloud.google.com/datastore/docs/concepts/queries#Datastore_Query_cursors
Type | Name | Description |
---|---|---|
string | Buffer
|
end |
Type | Description |
---|---|
this | {Query} |
filter(property, value)
filter
(
property
:
string
,
value
:
{})
:
Query
;
Type | Name | Description |
---|---|---|
string
|
property | |
{}
|
value |
Type | Description |
---|---|
Query |
filter(property, operator, value)
filter
(
property
:
string
,
operator
:
Operator
,
value
:
{})
:
Query
;
Type | Name | Description |
---|---|---|
string
|
property | |
Operator
|
operator | |
{}
|
value |
Type | Description |
---|---|
Query |
groupBy(fieldNames)
groupBy
(
fieldNames
:
string
|
string
[])
:
this
;
Group query results by a list of properties.
Type | Name | Description |
---|---|---|
string | string[]
|
fieldNames |
Type | Description |
---|---|
this | {Query} |
hasAncestor(key)
hasAncestor
(
key
:
Key
)
:
this
;
Filter a query by ancestors.
[Datastore Ancestor Filters] https://cloud.google.com/datastore/docs/concepts/queries#datastore-ancestor-query-nodejs
Type | Name | Description |
---|---|---|
Key
|
key | Key object to filter by. |
Type | Description |
---|---|
this | {Query} |
limit(n)
limit
(
n
:
number
)
:
this
;
Set a limit on a query.
[Query Limits] https://cloud.google.com/datastore/docs/concepts/queries#datastore-limit-nodejs
Type | Name | Description |
---|---|---|
number
|
n | The number of results to limit the query to. |
Type | Description |
---|---|
this | {Query} |
offset(n)
offset
(
n
:
number
)
:
this
;
Set an offset on a query.
[Query Offsets] https://cloud.google.com/datastore/docs/concepts/queries#datastore-limit-nodejs
Type | Name | Description |
---|---|---|
number
|
n | The offset to start from after the start cursor. |
Type | Description |
---|---|
this | {Query} |
order(property, options)
order
(
property
:
string
,
options
?:
OrderOptions
)
:
this
;
Sort the results by a property name in ascending or descending order. By default, an ascending sort order will be used.
[Datastore Sort Orders] https://cloud.google.com/datastore/docs/concepts/queries#datastore-ascending-sort-nodejs
Type | Name | Description |
---|---|---|
string
|
property | The property to order by. |
OrderOptions
|
options | Options object. |
Type | Description |
---|---|
this | {Query} |
run(options)
run
(
options
?:
RunQueryOptions
)
:
Promise<RunQueryResponse>
;
Type | Name | Description |
---|---|---|
RunQueryOptions
|
options |
Type | Description |
---|---|
Promise < RunQueryResponse > |
run(options, callback)
run
(
options
:
RunQueryOptions
,
callback
:
RunQueryCallback
)
:
void
;
Type | Name | Description |
---|---|---|
RunQueryOptions
|
options | |
RunQueryCallback
|
callback |
Type | Description |
---|---|
void |
run(callback)
run
(
callback
:
RunQueryCallback
)
:
void
;
Type | Name | Description |
---|---|---|
RunQueryCallback
|
callback |
Type | Description |
---|---|
void |
runStream(options)
runStream
(
options
?:
RunQueryStreamOptions
)
:
import
(
"stream"
).
Transform
;
Run the query as a readable object stream.
Query#runStream
Type | Name | Description |
---|---|---|
RunQueryStreamOptions
|
options | Optional configuration. See for a complete list of options. |
Type | Description |
---|---|
import("stream"). internal.Transform | {stream} |
select(fieldNames)
select
(
fieldNames
:
string
|
string
[])
:
this
;
Retrieve only select properties from the matched entities.
Queries that select a subset of properties are called Projection Queries.
[Projection Queries] https://cloud.google.com/datastore/docs/concepts/projectionqueries
Type | Name | Description |
---|---|---|
string | string[]
|
fieldNames | Properties to return from the matched entities. |
Type | Description |
---|---|
this | {Query} |
start(start)
start
(
start
:
string
|
Buffer
)
:
this
;
Set a starting cursor to a query.
[Query Cursors] https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets
Type | Name | Description |
---|---|---|
string | Buffer
|
start |
Type | Description |
---|---|
this | {Query} |