Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor refactoring #277

Merged
merged 1 commit into from
Mar 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class BrowserKeyValuePersister extends KeyValuePersister {

_writeToPersistance(collection, entities) {
return this._ensureCollectionExists(collection)
.then(() => this._deserializeAndSet(collection, entities));
.then(() => this._serializeAndSet(collection, entities));
}

_deleteFromPersistance(collection) {
Expand All @@ -57,11 +57,11 @@ export class BrowserKeyValuePersister extends KeyValuePersister {
return Promise.resolve();
}
allCollections.push(collection);
return this._deserializeAndSet(masterCollectionName, allCollections);
return this._serializeAndSet(masterCollectionName, allCollections);
});
}

_deserializeAndSet(collection, entities) {
_serializeAndSet(collection, entities) {
return this._serialize(entities)
.then(serialized => this._store.setItem(collection, serialized));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ export class IndexedDbKeyValueStorePersister extends KeyValueStorePersister {
};

txn.onerror = () => {
reject(new NotFoundError(`An entity with id = ${entityId} was not found in the ${collection}`
+ ` collection on the ${this._storeName} IndexedDB database.`));
reject(this._getEntityNotFoundError(collection, entityId));
};
}, reject);
});
Expand Down
2 changes: 1 addition & 1 deletion src/core/datastore/persisters/key-value-store-persister.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ export class KeyValueStorePersister extends KeyValuePersister {

_getEntityNotFoundError(collection, id) {
return new NotFoundError(`An entity with _id = ${id} was not found in the ${collection}`
+ ` collection on the ${this._storeName} IndexedDB database.`);
+ ` collection on the ${this._storeName} database.`);
}
}
3 changes: 1 addition & 2 deletions src/core/datastore/repositories/repository-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { StorageProvider } from './storage-provider';
import { ensureArray } from '../../utils';
import { PromiseQueueByKey } from '../utils';
import { MemoryKeyValuePersister } from '../persisters';

const testSupportCollection = '__testSupport__';
import { testSupportCollection } from './utils';

const inmemoryRepoBuilder = (queue) => {
const persister = new MemoryKeyValuePersister();
Expand Down
2 changes: 2 additions & 0 deletions src/core/datastore/repositories/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Client } from '../../client';

import { stripTagFromCollectionName } from '../utils';

export const testSupportCollection = '__testSupport__';

export function buildCollectionUrl(collectionName, id, restAction) {
collectionName = stripTagFromCollectionName(collectionName);
let result = `appdata/${Client.sharedInstance().appKey}/${collectionName}`;
Expand Down
2 changes: 0 additions & 2 deletions src/core/datastore/sync/sync-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export class SyncManager {
return Promise.reject(new KinveyError('Invalid or missing collection name'));
}

// TODO: decide on default value of pagination setting
if (options && (options.autoPagination && !options.useDeltaFetch)) {
return this._paginatedPull(collection, query, options);
}
Expand Down Expand Up @@ -291,7 +290,6 @@ export class SyncManager {
}

_fetchItemsFromServer(collection, query, options) {
// TODO: deltaset logic goes here
return this._networkRepo.read(collection, query, options);
}

Expand Down