react-native-ibm-mobilefirst-jsonstore
Version:
React Native SDK for IBM JSONStore. Works with IBM Mobile First
61 lines (52 loc) • 2.24 kB
JavaScript
/* Licensed Materials - Property of IBM
* 5725-I43 (C) Copyright IBM Corp. 2018. All Rights Reserved.
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/* author - Yash Soni | yashsoni21@in.ibm.com */
import { _checkParamType, _checkParamClassType, _mandatoryParam, ParamTypes } from './Utils'
/**
* Options that are used to control the add operation in JSONStoreCollection.
*/
class JSONStoreAddOptions {
/**
* @type {boolean}
*/
markDirty;
/**
* @type {JSON}
*/
addAdditionalSearchFields;
/**
* Constructor
* @param {string} [markDirty] - Flag to mark a document dirty. Default is false.
* @param {JSON} [additionalSearchFields] - additional search fields for the add operation.
*/
constructor(markDirty = false, additionalSearchFields = {}) {
_checkParamType(markDirty, ParamTypes.BOOLEAN);
_checkParamClassType(additionalSearchFields, Object);
this.markDirty = markDirty;
this.additionalSearchFields = additionalSearchFields;
}
/**
* Add an additional search field for the add operation.
* @param {string} key - The key of additional search field to include with the document.
* @param {any} value - The value of additional search field for 'key' to include with the document. Accepted value types are: ('string', 'boolean', 'integer', 'number')
*/
addAdditionalSearchField(key = _mandatoryParam('key'), value = _mandatoryParam('value')) {
_checkParamType(key, ParamTypes.STRING);
this.additionalSearchFields[key] = value;
}
/**
* Add multiple additional search fields for the add operation.
* @param {JSON} extraSearchFields - An JSON Object that contains key/value pairs for additional search fields.
*/
addAdditionalSearchFields(extraSearchFields = _mandatoryParam('extraSearchFields')) {
_checkParamClassType(extraSearchFields, Object);
var keys = Object.keys(extraSearchFields);
for (i in keys) {
this.additionalSearchFields[keys[i]] = extraSearchFields[keys[i]];
}
}
}
export default JSONStoreAddOptions