yylib-quick-mobile
Version:
yylib-quick-mobile
123 lines (101 loc) • 4.67 kB
JavaScript
'use strict';
var React = require('react');
var _ = require('lodash');
var ajax = require('../../utils/ajax');
var _require = require('../../common/RestUrl'),
ADDR = _require.ADDR;
var BaseWeb = ADDR + "/icop-elasticsearch-web";
var EsStore = {
saveMetadata: function saveMetadata(options) {
var index = options.index,
type = options.type,
metadataModel = options.metadataModel;
ajax.postJSON(BaseWeb + '/setMetadata', { index: index, type: type, metadataModel: metadataModel }, success, error);
},
save: function save(options) {
var index = options.index,
type = options.type,
data = options.data,
success = options.success,
error = options.error,
refresh = options.refresh;
ajax.postJSON(BaseWeb + '/elasticsearch/index', { index: index, type: type, doc: data, refresh: refresh ? refresh : true }, success, error);
},
batchSave: function batchSave(options) {
var index = options.index,
type = options.type,
data = options.data,
success = options.success,
error = options.error,
refresh = options.refresh;
ajax.postJSON(BaseWeb + '/elasticsearch/multiIndex', { index: index, type: type, docList: data, refresh: refresh ? refresh : true }, success, error);
},
update: function update(options) {
var index = options.index,
type = options.type,
id = options.id,
data = options.data,
success = options.success,
error = options.error,
refresh = options.refresh;
ajax.postJSON(BaseWeb + '/elasticsearch/update', { index: index, type: type, id: id, doc: data, refresh: refresh ? refresh : true }, success, error);
},
getOne: function getOne(options) {
var index = options.index,
type = options.type,
id = options.id,
success = options.success,
error = options.error;
ajax.postJSON(BaseWeb + '/elasticsearch/get', { index: index, type: type, id: id }, success, error);
},
deleteOne: function deleteOne(options) {
var index = options.index,
type = options.type,
id = options.id,
success = options.success,
error = options.error,
refresh = options.refresh;
ajax.delJSON(BaseWeb + '/elasticsearch/delete', { index: index, type: type, id: id, refresh: refresh ? refresh : true }, success, error);
},
deleteBatch: function deleteBatch(options) {
var index = options.index,
type = options.type,
ids = options.ids,
success = options.success,
error = options.error,
refresh = options.refresh;
ajax.delJSON(BaseWeb + '/elasticsearch/multiDelete', { index: index, type: type, ids: ids, refresh: refresh ? refresh : true }, success, error);
},
findOne: function findOne(options) {
var index = options.index,
type = options.type,
simpleCriteria = options.simpleCriteria,
orderRules = options.orderRules,
success = options.success,
error = options.error;
ajax.postJSON(BaseWeb + '/elasticsearch/filterForObject', { index: index, type: type, simpleCriteria: simpleCriteria, orderRules: orderRules }, success, error);
},
queryList: function queryList(options) {
var index = options.index,
type = options.type,
pageNumber = options.pageNumber,
pageSize = options.pageSize,
searchText = options.searchText,
simpleCriteria = options.simpleCriteria,
orderRules = options.orderRules,
success = options.success,
error = options.error;
ajax.postJSON(BaseWeb + '/elasticsearch/filterForPage', { index: index, type: type, pageNumber: pageNumber, pageSize: pageSize, searchText: searchText, simpleCriteria: simpleCriteria, orderRules: orderRules }, success, error);
},
queryAll: function queryAll(options) {
var index = options.index,
type = options.type,
searchText = options.searchText,
simpleCriteria = options.simpleCriteria,
orderRules = options.orderRules,
success = options.success,
error = options.error;
ajax.postJSON(BaseWeb + '/elasticsearch/filterForList', { index: index, type: type, searchText: searchText, simpleCriteria: simpleCriteria, orderRules: orderRules }, success, error);
}
};
module.exports = EsStore;