localforage vs lowdb vs levelup vs node-persist vs pouchdb vs nedb
Veri Depolama Kütüphaneleri
localforagelowdblevelupnode-persistpouchdbnedbBenzer Paketler:

Veri Depolama Kütüphaneleri

Bu kütüphaneler, JavaScript uygulamalarında veri depolamak için kullanılan çeşitli çözümler sunar. Her biri farklı özellikler ve kullanım senaryoları ile gelir, bu da geliştiricilerin ihtiyaçlarına göre en uygun olanı seçmelerine olanak tanır.

npm İndirme Trendi

3 Yıl

GitHub Stars Sıralaması

İstatistik Detayı

Paket
İndirmeler
Stars
Boyut
Issues
Yayın Tarihi
Lisans
localforage11,392,87625,806-251il y a 5 ansApache-2.0
lowdb2,209,85522,58222.9 kB17il y a 3 ansMIT
levelup1,306,2574,066-0il y a 5 ansMIT
node-persist176,57872640.1 kB17il y a 2 ansMIT
pouchdb94,90617,6255.53 MB196il y a 2 ansApache-2.0
nedb73,77313,524-208il y a 11 ansSEE LICENSE IN LICENSE

Özellik Karşılaştırması: localforage vs lowdb vs levelup vs node-persist vs pouchdb vs nedb

Veri Yapısı

  • localforage:

    LocalForage, tarayıcıda veri saklamak için anahtar-değer çiftleri kullanır ve farklı arka uçlar arasında geçiş yapma yeteneği sunar.

  • lowdb:

    LowDB, JSON dosyalarını kullanarak veri saklar. Bu, verilerin kolayca okunmasını ve yazılmasını sağlar.

  • levelup:

    LevelUP, verileri anahtar-değer çiftleri olarak saklar ve LevelDB üzerinde çalışır. Bu yapı, yüksek performans ve ölçeklenebilirlik sağlar.

  • node-persist:

    Node-Persist, basit bir anahtar-değer depolama yapısı sunar ve verilerinizi dosya sisteminde saklar.

  • pouchdb:

    PouchDB, verileri JSON formatında saklar ve CouchDB ile senkronize olma yeteneğine sahiptir.

  • nedb:

    NeDB, MongoDB benzeri bir API ile anahtar-değer çiftleri şeklinde veri saklar. Bu, geliştiricilerin tanıdık bir yapı ile çalışmasını sağlar.

Kullanım Senaryoları

  • localforage:

    LocalForage, tarayıcı tabanlı uygulamalarda kullanıcı verilerini saklamak için mükemmeldir. Offline erişim gerektiren uygulamalar için idealdir.

  • lowdb:

    LowDB, küçük projeler ve prototipler için uygun bir çözümdür. Hızlı bir şekilde veri yapısı oluşturmak isteyenler için idealdir.

  • levelup:

    LevelUP, büyük veri setleri ve yüksek performans gerektiren uygulamalar için idealdir. Örneğin, gerçek zamanlı veri analizi uygulamaları için uygundur.

  • node-persist:

    Node-Persist, basit anahtar-değer depolama gereksinimleri için idealdir. Küçük uygulamalar ve araçlar için mükemmel bir çözümdür.

  • pouchdb:

    PouchDB, offline uygulamalar ve veri senkronizasyonu gerektiren durumlar için mükemmel bir çözümdür.

  • nedb:

    NeDB, küçük ve orta ölçekli uygulamalar için uygundur. Yerel veri saklama ihtiyacı olan Node.js uygulamaları için iyi bir seçimdir.

Performans

  • localforage:

    LocalForage, tarayıcıda veri saklarken hızlı bir performans sunar, ancak büyük veri setlerinde performans düşebilir.

  • lowdb:

    LowDB, küçük veri setleri için hızlıdır, ancak büyük veri setlerinde performans sorunları yaşayabilir.

  • levelup:

    LevelUP, yüksek performans sunar ve büyük veri setleriyle çalışırken hızlı erişim sağlar. LevelDB'nin performans avantajlarından yararlanır.

  • node-persist:

    Node-Persist, basit veri saklama işlemleri için yeterli performans sunar, ancak büyük veri setlerinde yavaşlayabilir.

  • pouchdb:

    PouchDB, offline ve senkronizasyon özellikleri ile iyi bir performans sunar, ancak karmaşık sorgularda yavaşlayabilir.

  • nedb:

    NeDB, küçük veri setleri için yeterli performansı sunar, ancak büyük veri setlerinde yavaşlayabilir.

Öğrenme Eğrisi

  • localforage:

    LocalForage, basit bir API sunduğu için öğrenmesi kolaydır. Tarayıcı tabanlı uygulamalar için hızlı bir şekilde kullanılabilir.

  • lowdb:

    LowDB, basit bir yapı sunduğu için öğrenmesi oldukça kolaydır. JSON ile çalışmak, geliştiriciler için tanıdık bir deneyim sunar.

  • levelup:

    LevelUP, LevelDB'ye aşina olmayanlar için öğrenme eğrisi gerektirebilir. Ancak, iyi bir dokümantasyon ile öğrenmek mümkündür.

  • node-persist:

    Node-Persist, basit bir anahtar-değer depolama yapısı sunduğu için öğrenmesi kolaydır.

  • pouchdb:

    PouchDB, senkronizasyon ve offline özellikleri ile birlikte biraz daha karmaşık bir öğrenme eğrisi sunabilir.

  • nedb:

    NeDB, MongoDB benzeri bir API sunduğu için, MongoDB bilenler için öğrenmesi kolaydır.

Senkronizasyon Özellikleri

  • localforage:

    LocalForage, tarayıcıda veri senkronizasyonu sağlamaz, ancak farklı depolama mekanizmaları arasında geçiş yapabilir.

  • lowdb:

    LowDB, senkronizasyon özellikleri sunmaz, yalnızca yerel dosya sistemi ile çalışır.

  • levelup:

    LevelUP, senkronizasyon özellikleri sunmaz, ancak LevelDB ile birlikte kullanılabilir.

  • node-persist:

    Node-Persist, basit bir anahtar-değer depolama çözümüdür ve senkronizasyon sağlamaz.

  • pouchdb:

    PouchDB, CouchDB ile senkronizasyon yeteneğine sahiptir ve offline veri erişimi sağlar.

  • nedb:

    NeDB, yerel veri saklama sağlar, ancak senkronizasyon özellikleri yoktur.

Nasıl Seçilir: localforage vs lowdb vs levelup vs node-persist vs pouchdb vs nedb

  • localforage:

    LocalForage, tarayıcıda yerel depolama için basit bir API sunar ve IndexedDB, WebSQL ve localStorage gibi çeşitli depolama mekanizmalarını kullanır. Tarayıcı uyumluluğu önemliyse ve basit bir kullanım arıyorsanız, LocalForage tercih edilebilir.

  • lowdb:

    LowDB, basit JSON dosyalarını kullanarak veri depolamak için hafif bir çözüm sunar. Küçük projeler veya prototipler için idealdir. Eğer hızlı bir şekilde veri yapınızı oluşturmak istiyorsanız, LowDB iyi bir seçimdir.

  • levelup:

    LevelUP, Node.js ile birlikte çalışmak üzere tasarlanmıştır ve yüksek performanslı bir veri depolama çözümü arayanlar için uygundur. Eğer verilerinizi bir veritabanında saklamak istiyorsanız ve LevelDB gibi bir arka uç kullanıyorsanız, LevelUP iyi bir seçimdir.

  • node-persist:

    Node-Persist, basit bir anahtar-değer depolama çözümüdür. Node.js uygulamalarında kolayca kullanılabilir ve verilerinizi dosya sisteminde saklamak için idealdir. Eğer basit bir anahtar-değer depolama çözümü arıyorsanız, Node-Persist iyi bir seçimdir.

  • pouchdb:

    PouchDB, tarayıcılar ve Node.js için tasarlanmış bir veritabanıdır ve CouchDB ile senkronizasyon yeteneğine sahiptir. Eğer offline destek ve veri senkronizasyonu önemliyse, PouchDB en iyi seçimdir.

  • nedb:

    NeDB, MongoDB benzeri bir API sunan hafif bir veritabanıdır. Node.js uygulamaları için uygundur ve verilerinizi yerel olarak saklamak istiyorsanız iyi bir alternatif sunar. Eğer MongoDB ile benzer bir deneyim arıyorsanız, NeDB tercih edilebilir.

localforage için README

localForage

Build Status NPM version Dependency Status npm jsDelivr Hits minzipped size

localForage is a fast and simple storage library for JavaScript. localForage improves the offline experience of your web app by using asynchronous storage (IndexedDB or WebSQL) with a simple, localStorage-like API.

localForage uses localStorage in browsers with no IndexedDB or WebSQL support. See the wiki for detailed compatibility info.

To use localForage, just drop a single JavaScript file into your page:

<script src="localforage/dist/localforage.js"></script>
<script>localforage.getItem('something', myCallback);</script>

Try the live example.

Download the latest localForage from GitHub, or install with npm:

npm install localforage

Support

Lost? Need help? Try the localForage API documentation. localForage API文档也有中文版。

If you're having trouble using the library, running the tests, or want to contribute to localForage, please look through the existing issues for your problem first before creating a new one. If you still need help, feel free to file an issue.

How to use localForage

Callbacks vs Promises

Because localForage uses async storage, it has an async API. It's otherwise exactly the same as the localStorage API.

localForage has a dual API that allows you to either use Node-style callbacks or Promises. If you are unsure which one is right for you, it's recommended to use Promises.

Here's an example of the Node-style callback form:

localforage.setItem('key', 'value', function (err) {
  // if err is non-null, we got an error
  localforage.getItem('key', function (err, value) {
    // if err is non-null, we got an error. otherwise, value is the value
  });
});

And the Promise form:

localforage.setItem('key', 'value').then(function () {
  return localforage.getItem('key');
}).then(function (value) {
  // we got our value
}).catch(function (err) {
  // we got an error
});

Or, use async/await:

try {
    const value = await localforage.getItem('somekey');
    // This code runs once the value has been loaded
    // from the offline store.
    console.log(value);
} catch (err) {
    // This code runs if there were any errors.
    console.log(err);
}

For more examples, please visit the API docs.

Storing Blobs, TypedArrays, and other JS objects

You can store any type in localForage; you aren't limited to strings like in localStorage. Even if localStorage is your storage backend, localForage automatically does JSON.parse() and JSON.stringify() when getting/setting values.

localForage supports storing all native JS objects that can be serialized to JSON, as well as ArrayBuffers, Blobs, and TypedArrays. Check the API docs for a full list of types supported by localForage.

All types are supported in every storage backend, though storage limits in localStorage make storing many large Blobs impossible.

Configuration

You can set database information with the config() method. Available options are driver, name, storeName, version, size, and description.

Example:

localforage.config({
    driver      : localforage.WEBSQL, // Force WebSQL; same as using setDriver()
    name        : 'myApp',
    version     : 1.0,
    size        : 4980736, // Size of database, in bytes. WebSQL-only for now.
    storeName   : 'keyvaluepairs', // Should be alphanumeric, with underscores.
    description : 'some description'
});

Note: you must call config() before you interact with your data. This means calling config() before using getItem(), setItem(), removeItem(), clear(), key(), keys() or length().

Multiple instances

You can create multiple instances of localForage that point to different stores using createInstance. All the configuration options used by config are supported.

var store = localforage.createInstance({
  name: "nameHere"
});

var otherStore = localforage.createInstance({
  name: "otherName"
});

// Setting the key on one of these doesn't affect the other.
store.setItem("key", "value");
otherStore.setItem("key", "value2");

RequireJS

You can use localForage with RequireJS:

define(['localforage'], function(localforage) {
    // As a callback:
    localforage.setItem('mykey', 'myvalue', console.log);

    // With a Promise:
    localforage.setItem('mykey', 'myvalue').then(console.log);
});

TypeScript

If you have the allowSyntheticDefaultImports compiler option set to true in your tsconfig.json (supported in TypeScript v1.8+), you should use:

import localForage from "localforage";

Otherwise you should use one of the following:

import * as localForage from "localforage";
// or, in case that the typescript version that you are using
// doesn't support ES6 style imports for UMD modules like localForage
import localForage = require("localforage");

Framework Support

If you use a framework listed, there's a localForage storage driver for the models in your framework so you can store data offline with localForage. We have drivers for the following frameworks:

If you have a driver you'd like listed, please open an issue to have it added to this list.

Custom Drivers

You can create your own driver if you want; see the defineDriver API docs.

There is a list of custom drivers on the wiki.

Working on localForage

You'll need node/npm and bower.

To work on localForage, you should start by forking it and installing its dependencies. Replace USERNAME with your GitHub username and run the following:

# Install bower globally if you don't have it:
npm install -g bower

# Replace USERNAME with your GitHub username:
git clone [email protected]:USERNAME/localForage.git
cd localForage
npm install
bower install

Omitting the bower dependencies will cause the tests to fail!

Running Tests

You need PhantomJS installed to run local tests. Run npm test (or, directly: grunt test). Your code must also pass the linter.

localForage is designed to run in the browser, so the tests explicitly require a browser environment. Local tests are run on a headless WebKit (using PhantomJS).

When you submit a pull request, tests will be run against all browsers that localForage supports on Travis CI using Sauce Labs.

Library Size

As of version 1.7.3 the payload added to your app is rather small. Served using gzip compression, localForage will add less than 10k to your total bundle size:

minified
`~29kB`
gzipped
`~8.8kB`
brotli'd
`~7.8kB`

License

This program is free software; it is distributed under an Apache License.


Copyright (c) 2013-2016 Mozilla (Contributors).