• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15import { AsyncCallback } from '../../basic'
16
17/**
18 * Provides methods for accessing a database result set generated by querying the database.
19 *
20 * @since 7
21 * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
22 * @import import data_rdb from '@ohos.data.rdb';
23 */
24export interface ResultSet {
25    /**
26     * Obtains the names of all columns in a result set.
27     *
28     * @note The column names are returned as a string array, in which the strings are in the same order
29     * as the columns in the result set.
30     * @since 7
31     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
32     */
33    columnNames: Array<string>;
34
35    /**
36     * Obtains the number of columns in the result set.
37     *
38     * @note The returned number is equal to the length of the string array returned by the
39     * columnCount method.
40     * @since 7
41     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
42     */
43    columnCount: number;
44
45    /**
46     * Obtains the number of rows in the result set.
47     *
48     * @note N/A
49     * @since 7
50     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
51     */
52    rowCount: number;
53
54    /**
55     * Obtains the current index of the result set.
56     *
57     * @note The result set index starts from 0.
58     * @since 7
59     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
60     */
61    rowIndex: number;
62
63    /**
64     * Checks whether the result set is positioned at the first row.
65     *
66     * @note N/A
67     * @since 7
68     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
69     */
70    isAtFirstRow: boolean;
71
72    /**
73     * Checks whether the result set is positioned at the last row.
74     *
75     * @note N/A
76     * @since 7
77     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
78     */
79    isAtLastRow: boolean;
80
81    /**
82     * Checks whether the result set is positioned after the last row.
83     *
84     * @note N/A
85     * @since 7
86     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
87     */
88    isEnded: boolean;
89
90    /**
91     * Returns whether the cursor is pointing to the position before the first
92     * row.
93     *
94     * @note N/A
95     * @since 7
96     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
97     */
98    isStarted: boolean;
99
100    /**
101     * Checks whether the current result set is closed.
102     *
103     * If the result set is closed by calling the close method, true will be returned.
104     *
105     * @note N/A
106     * @since 7
107     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
108     */
109    isClosed: boolean;
110
111    /**
112     * Obtains the column index based on the specified column name.
113     *
114     * @note The column name is passed as an input parameter.
115     * @since 7
116     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
117     * @param columnName Indicates the name of the specified column in the result set.
118     * @return Returns the index of the specified column.
119     */
120    getColumnIndex(columnName: string): number;
121
122    /**
123     * Obtains the column name based on the specified column index.
124     *
125     * @note The column index is passed as an input parameter.
126     * @since 7
127     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
128     * @param columnIndex Indicates the index of the specified column in the result set.
129     * @return Returns the name of the specified column.
130     */
131    getColumnName(columnIndex: number): string;
132
133    /**
134     * Go to the specified row of the result set forwards or backwards by an offset relative to its current position.
135     * A positive offset indicates moving backwards, and a negative offset indicates moving forwards.
136     *
137     * @note N/A
138     * @since 7
139     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
140     * @param offset Indicates the offset relative to the current position.
141     * @return Returns true if the result set is moved successfully and does not go beyond the range;
142     * returns false otherwise.
143     */
144    goTo(offset: number): boolean;
145
146    /**
147     * Go to the specified row of the result set.
148     *
149     * @note N/A
150     * @since 7
151     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
152     * @param rowIndex Indicates the index of the specified row, which starts from 0.
153     * @return Returns true if the result set is moved successfully; returns false otherwise.
154     */
155    goToRow(position: number): boolean;
156
157    /**
158     * Go to the first row of the result set.
159     *
160     * @note N/A
161     * @since 7
162     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
163     * @return Returns true if the result set is moved successfully;
164     * returns false otherwise, for example, if the result set is empty.
165     */
166    goToFirstRow(): boolean;
167
168    /**
169     * Go to the last row of the result set.
170     *
171     * @note N/A
172     * @since 7
173     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
174     * @return Returns true if the result set is moved successfully;
175     * returns false otherwise, for example, if the result set is empty.
176     */
177    goToLastRow(): boolean;
178
179    /**
180     * Go to the next row of the result set.
181     *
182     * @note N/A
183     * @since 7
184     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
185     * @return Returns true if the result set is moved successfully;
186     * returns false otherwise, for example, if the result set is already in the last row.
187     */
188    goToNextRow(): boolean;
189
190    /**
191     * Go to the previous row of the result set.
192     *
193     * @note N/A
194     * @since 7
195     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
196     * @return Returns true if the result set is moved successfully;
197     * returns false otherwise, for example, if the result set is already in the first row.
198     */
199    goToPreviousRow(): boolean;
200
201    /**
202     * Obtains the value of the specified column in the current row as a byte array.
203     *
204     * @note The implementation class determines whether to throw an exception if the value of the specified column
205     * in the current row is null or the specified column is not of the Blob type.
206     * @since 7
207     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
208     * @param columnIndex Indicates the specified column index, which starts from 0.
209     * @return Returns the value of the specified column as a byte array.
210     */
211    getBlob(columnIndex: number): Uint8Array;
212
213    /**
214     * Obtains the value of the specified column in the current row as string.
215     *
216     * @note The implementation class determines whether to throw an exception if the value of the specified column
217     * in the current row is null or the specified column is not of the string type.
218     * @since 7
219     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
220     * @param columnIndex Indicates the specified column index, which starts from 0.
221     * @return Returns the value of the specified column as a string.
222     */
223    getString(columnIndex: number): string;
224
225    /**
226     * Obtains the value of the specified column in the current row as long.
227     *
228     * @note The implementation class determines whether to throw an exception if the value of the specified column
229     * in the current row is null, the specified column is not of the integer type.
230     * @since 7
231     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
232     * @param columnIndex Indicates the specified column index, which starts from 0.
233     * @return Returns the value of the specified column as a long.
234     */
235    getLong(columnIndex: number): number;
236
237    /**
238     * Obtains the value of the specified column in the current row as double.
239     *
240     * @note The implementation class determines whether to throw an exception if the value of the specified column
241     * in the current row is null, the specified column is not of the double type.
242     * @since 7
243     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
244     * @param columnIndex Indicates the specified column index, which starts from 0.
245     * @return Returns the value of the specified column as a double.
246     */
247    getDouble(columnIndex: number): number;
248
249    /**
250     * Checks whether the value of the specified column in the current row is null.
251     *
252     * @note N/A
253     * @since 7
254     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
255     * @param columnIndex Indicates the specified column index, which starts from 0.
256     * @return Returns true if the value of the specified column in the current row is null;
257     * returns false otherwise.
258     */
259    isColumnNull(columnIndex: number): boolean;
260
261    /**
262     * Closes the result set.
263     *
264     * @note Calling this method on the result set will release all of its resources and makes it ineffective.
265     * @since 7
266     * @syscap SystemCapability.DistributedDataManager.RelationalStore.Core
267     * @return Returns true if the result set is closed; returns false otherwise.
268     */
269    close(): void;
270}