npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

feathers-offline-snapshot

v0.0.7

Published

Offline-first snapshot strategy. Read selected data from a service.

Downloads

31

Readme

feathers-offline-snapshot

Greenkeeper badge

Build Status Code Climate Test Coverage Dependency Status Download Status

Offline-first snapshot strategy. Read selected records from service.

Installation

npm install feathers-offline-snapshot --save

Documentation

import snapshot from 'feathers-offline-snapshot';
snapshort(service, query).then(records => ...);
  • service (required) - The service to read.
  • query (optional, default: {}) - The Feathers query object selecting the records to read. Some of the props it may include are:
    • $limit (optional, default: 200) - Records to read at a time. The service's configuration may limit the actual number read.
    • $skip (optional, default: 0) will initially skip this number of records.
    • $sort (optional, default: {}) will sort the records. You can sort on multiple props, for example { field1: 1, field2: -1 }.

Example

const snapshot = require('feathers-offline-snapshot');

const app = ... // Configure Feathers, including the `/messages` service.
const username = ... // The username authenticated on this client
const messages = app.service('/messages');

snapshot(messages, { username, $sort: { channel: 1 } })
  .then(records => {
    console.log(records);
  });

What is the Snapshot strategy?

Snapshot distributes data exactly as it appears at a specific moment in time and does not monitor for updates to the data. When synchronization occurs, the entire snapshot is generated and sent to client service.

Snapshot can be used by itself, but the snapshot process is also commonly used to provide the initial set of data for all the other strategies.

Using Snapshot by itself is most appropriate when one or more of the following is true:

  • Data changes infrequently.
  • It is acceptable to have copies of data that are out of date with respect to the remote service for a period of time.
  • Replicating small or medium volumes of data.
  • A large volume of changes occurs over a short period of time.
  • Keep the current values after having lost connection for some time.

Snapshot replication is most appropriate when data changes are substantial but infrequent. For example, if a sales organization maintains a product price list and the prices are all updated at the same time once or twice each year, replicating the entire snapshot of data after it has changed is recommended. Given certain types of data, more frequent snapshots may also be appropriate. For example, if a relatively small table is updated on a remote service during the day, but some latency is acceptable, changes can be delivered nightly as a snapshot.

Snapshot has a lower continuous overhead on both the client and the remote than the other strategies, because incremental changes are not tracked. However, if the dataset set is very large, it will require substantial resources to generate and apply the snapshot. Consider the size of the entire data set and the frequency of changes to the data when evaluating whether to utilize snapshot replication.

(*)

Snapshot Case Study

Let's consider a mobile application for movie cinemas, which lists show times.

Cinema panels

Let's assess the data problem.

  • Cinemas change once a year.
  • The schedule changes every Thursday.
  • The static information rarely changes.
  • We need to support ticket reservations.
  • We don't need past data.

Let's look at the data. We need:

  • 12 cimema photos + their names + coordinates
  • 25 film posters + film names
  • 30 movie times for each cinemas

This is about 7k of files and 2M of photos, which takes less space than 1 Facebook photo.

The problem definition contains the solution:

Cinema flowchart

The snapshot strategy is the simplest one to satisfy the needs.

How about ticket reservations? You got to do some things online! However, you can still give a telephone number.

(**)

Sources:

License

Copyright (c) 2017

Licensed under the MIT license.