Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var results = [];
openRequest.onsuccess = function(e) {
var cursor = e.target.result;
if (cursor) {
results.push(cursor.value);
cursor.continue();
} else {
resolve(results);
}
};
openRequest.onerror = (e) => reject(e.targer.error);
});
}
// monkey-patch the query interface to rely setup being ready
Client.Bucket.prototype.query = function(fn) {
const store = this.store,
bucket = this;
var query = new Query(function(query) {
return store.setup.then(
(db) => performQuery(db, query, bucket),
(e) => console.error("Failed to query %s", bucket.name, e)
);
});
if (fn) {
query.exec(fn);
}
return query;
}
export default function(database, version, config) {
// TODO: sorting, filtering, etc
Client.Bucket.prototype.query = function(fn) {
var bucket = this,
query = new Query(function(query) {
return (new Promise(function(resolve, reject) {
var objects = [];
for (var id in bucket.store.objects) {
objects.push(bucket.store.objects[id]);
}
resolve(objects);
})).catch((e) => { console.error("Failed to query", e)})
});
if (fn) {
query.exec(fn);
}
return query;
export default function configure(database, version, config) {
Client.Bucket.prototype.query = function(fn) {
return this.store.query(fn);
};
var setup = setupObjectStore(database, version, config)
.catch((e) => console.error("Failed to setup", e))
var ghostSetup = setupGhostStore()
.catch((e) => console.error("Failed to setup ghosts", e));
return {
ghostStoreProvider: function(bucket) {
return new GhostStore(ghostSetup, bucket);
},
objectStoreProvider: function(bucket) {
return new BucketStore(setup, bucket, config[bucket.name]);
},
import util from 'util';
import events from 'events';
export const Auth = simperium.Auth;
export default function(settings) {
const browserClient = new BrowserClient(settings);
window.addEventListener('beforeunload', () => {
Object.values(browserClient.buckets).forEach(localQueueStore.persist);
});
return browserClient;
}
Client.Bucket.prototype.query = function(fn) {
this.store.setup.then(fn);
};
function BrowserClient({ appID, token, bucketConfig, database, version }) {
this.databaseName = database || 'simperium-objects';
this.databaseVersion = version || 1;
let config = (this.bucketConfig = bucketConfig);
this.bucketDB = store_provider(this.configureDb.bind(this));
this.buckets = {};
let objectStoreProvider = this.bucketDB.provider();
this.ghostStore = ghost_store;
this.client = simperium(appID, token, {
ghostStoreProvider: ghost_store,
objectStoreProvider: function(bucket) {