background image
C H A P T E R 1 1
Data Storage and Retrieval
Using Newton Data Storage Objects
11-43
set operator to select entries marked with only the
'flower
and
'tall
tags; this
query does not select entries missing either tag, nor does it select entries marked
with additional tags:
local myCurs := mySoup:Query({indexPath:'name,
tagSpec: {equal: ['tall, 'flower]}});
Like the
equal
set operator, the
all
set operator specifies a set of tags that entries
must have to be selected; however, the
all
set operator does not exclude entries
marked with additional tags. For example, the query in the following example uses
the
all
set operator to select entries marked with both the
'flower
and
'tall
tags. This query excludes entries missing either of these tags but includes entries
marked with a superset of the
'flower
and
'tall
tags:
local myCurs := mySoup:Query({indexPath:'name,
tagSpec: {all: ['tall, 'flower]}});
The presence of any tag specified by the
none
set operator is sufficient to exclude
that entry from the query result. For example, the following query matches entries
having both of the tags
'flower
and
'tall
but excludes any entry marked with
the
'thorns
tag:
local myCurs := mySoup:Query({indexPath:'name,
tagSpec: {all:['flower, 'tall],
none:['thorns]}});
The following exceptions may be thrown when attempting to query using a tag
spec. If the soup does not have a tags index, a "no tags" exception
|
evt.ex.fr.store| -48027
is thrown. If the tag spec passed as an argument to
the
Query
method has none of the slots
equal
,
any
,
all
, or
none
, an "invalid
tag spec" exception |
evt.ex.fr.store
|
-48028
is thrown.
Querying for Text
11
This section describes how to select entries according to the presence of one or
more strings in any slot. The current system allows you to search entries for string
beginnings, entire strings, or substrings of larger strings.
To select entries according to the presence of one or more specified string
beginnings, add to your query spec a
words
slot containing an array of string
beginnings to be matched. For example, the following code fragment illustrates a
query that returns entries having strings beginning with
"bob"
:
// find words beginning with "bob"
local myCurs := mySoup:Query({words: ["bob"]});
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна