Browser version

The browser version and its minified counterpart are in the browser-version/out directory. You only need to require nedb.js or nedb.min.js in your HTML file and the global object Nedb can be used right away, with the same API as the server version:

  1. <script src="nedb.min.js"></script>
  2. <script>
  3. var db = new Nedb(); // Create an in-memory only datastore
  4. db.insert({ planet: 'Earth' }, function (err) {
  5. db.find({}, function (err, docs) {
  6. // docs contains the two planets Earth and Mars
  7. });
  8. });
  9. </script>

If you specify a filename, the database will be persistent, and automatically select the best storage method available (IndexedDB, WebSQL or localStorage) depending on the browser. In most cases that means a lot of data can be stored, typically in hundreds of MB. WARNING: the storage system changed between v1.3 and v1.4 and is NOT back-compatible! Your application needs to resync client-side when you upgrade NeDB.

NeDB is compatible with all major browsers: Chrome, Safari, Firefox, IE9+. Tests are in the browser-version/test directory (files index.html and testPersistence.html).

If you fork and modify nedb, you can build the browser version from the sources, the build script is browser-version/build.js.