How to use the simperium.Client.Bucket function in simperium

To help you get started, we’ve selected a few simperium examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Automattic / simplenote-electron / lib / simperium / indexeddb / index.js View on Github external
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;
	}
github Automattic / simplenote-electron / lib / simperium / memorydb / index.js View on Github external
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;
github Automattic / simplenote-electron / lib / simperium / websql / index.js View on Github external
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]);
		},
github Automattic / simplenote-electron / lib / simperium / index.js View on Github external
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) {

simperium

A simperium client for node.js

BSD-2-Clause
Latest version published 3 years ago

Package Health Score

52 / 100
Full package analysis