UNPKG

@mysql/xdevapi

Version:

MySQL Connector/Node.js - A Node.js driver for MySQL using the X Protocol and X DevAPI.

90 lines (87 loc) 3.84 kB
/* * Copyright (c) 2022, Oracle and/or its affiliates. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2.0, as * published by the Free Software Foundation. * * This program is also distributed with certain software (including * but not limited to OpenSSL) that is licensed under separate terms, * as designated in a particular file or component or in included license * documentation. The authors of MySQL hereby grant you an * additional permission to link the program and your derivative works * with the separately licensed software that they have included with * MySQL. * * Without limiting anything contained in the foregoing, this file, * which is part of MySQL Connector/Node.js, is also subject to the * Universal FOSS Exception, version 1.0, a copy of which can be found at * http://oss.oracle.com/licenses/universal-foss-exception. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License, version 2.0, for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ import Binding from './Binding'; import { DocumentOrJSON } from './CollectionAdd'; import Ordering from './CollectionOrdering'; import Limiting from './Limiting'; import Result from './Result'; import { ExprOrLiteral } from './Updating'; /** * Statement generated by `collection.modify()`. */ interface CollectionModify extends Binding<CollectionModify>, Limiting<CollectionModify>, Ordering<CollectionModify> { /** * Appends a value to an array field in all documents matching the * filtering criteria * @param field - The name of a field whose value is an array. * @param value - A value to append to the array. */ arrayAppend: (field: string, value: ExprOrLiteral) => CollectionModify /** * Prepends a value to an array filed in all documents matching the * filtering criteria. * @param field - The name of a field whose value is an array. * @param value - A value to prepend to the array. * @returns The current statement instance itself. */ arrayInsert: (field: string, value: ExprOrLiteral) => CollectionModify /** * Executes the current statement. * @returns A `Promise` that resolves to a `Result` instance once the * statement is executed. */ execute: () => Promise<Result> /** * Updates all documents matching the filterting criteria with the fields * and values specified by an object (`null` values will unset existing * fields). * @param properties - A plain JavaScript object or JSON literal * containing the fields and values to update. * @returns The current statement instance itself. */ patch: (properties: DocumentOrJSON) => CollectionModify /** * Updates a specific field with a given value on all documents matching * the filtering criteria. * @param field - The name of a document field. * @param value - The new value of that field. * @returns The current statement instance itself. */ set: (field: string, value: ExprOrLiteral) => CollectionModify /** * Removes a specific field from all documents matching the filtering * criteria. * @param fields - A name or an array of names of fields to remove * from the document. * @returns The current statement instance itself. */ unset: (fields: string | string[]) => CollectionModify } export default CollectionModify;