Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kinvey-flex-sdk

Package Overview
Dependencies
Maintainers
2
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kinvey-flex-sdk - npm Package Compare versions

Comparing version 3.3.0-alpha.2 to 3.3.0

55

lib/service/modules/dataStore.js

@@ -16,4 +16,6 @@ /**

const BaseStore = require('./baseStore');
const async = require('async');
const BASE_ROUTE = 'appdata';
const SAVE_BATCH_SIZE = 100;

@@ -37,2 +39,50 @@ // Initialize the DataStore; initializes to current User Context, unless useMasterSecret = true

_makeAppdataBatchRequest(requestOptions, entities, collectionName, callback) {
if (this._taskMetadata.objectName === collectionName && (this._useBl === true || this._useUserContext === true)) {
const error = new Error('DataStoreError');
error.description = 'Not Allowed';
error.debug = 'Recursive data operations to the same collection cannot use user context or use BL.';
return callback ? setImmediate(() => callback(error)) : Promise.reject(error);
}
// send multi-insert request in batches
const entitiesInBatches = [];
let start = 0;
while (start < entities.length) {
entitiesInBatches.push(entities.slice(start, start + SAVE_BATCH_SIZE));
start += SAVE_BATCH_SIZE;
}
const totalEntities = [];
const totalErrors = [];
return new Promise((resolve, reject) => {
async.eachOfSeries(entitiesInBatches, (batch, i, cb) => {
requestOptions.body = batch;
this._makeRequest(requestOptions, (err, resBody) => {
if (err) return cb(err);
totalEntities.push(...resBody.entities);
// change batch-specific index to absolute index
resBody.errors.forEach((e) => {
e.index = (SAVE_BATCH_SIZE * i) + e.index;
});
totalErrors.push(...resBody.errors);
cb();
});
}, (err) => {
if (err) {
return callback ? callback(err) : reject(err);
}
// form the result
const resBody = {
entities: totalEntities,
errors: totalErrors
};
return callback ? callback(null, resBody) : resolve(resBody);
});
});
}
collection(collectionName) {

@@ -56,4 +106,7 @@ const save = (entity, callback) => {

if (Array.isArray(entity) && entity.length > SAVE_BATCH_SIZE) {
return this._makeAppdataBatchRequest(requestOptions, entity, collectionName, callback);
}
requestOptions.body = entity;
return this._makeAppdataRequest(requestOptions, collectionName, callback);

@@ -60,0 +113,0 @@ };

3

package.json
{
"name": "kinvey-flex-sdk",
"version": "3.3.0-alpha.2",
"version": "3.3.0",
"description": "SDK for creating Kinvey Flex Services",

@@ -19,2 +19,3 @@ "engines": {

"dependencies": {
"async": "3.1.0",
"bson": "0.4.23",

@@ -21,0 +22,0 @@ "kinvey-code-task-runner": "2.4.0",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc