Get started with nedb CDN

MIT licensed

Nedb is a NoSQL database for Node.js, providing a simple key-value store interface.

Tags:
  • database
  • datastore
  • embedded

Stable version

Copied!

How to start using nedb CDN


const Nedb = require('nedb'); // Import Nedb
const db = new Nedb('database.db'); // Initialize a new database

db.loadDatabase(() => {
  console.log('Database loaded');

  // Define a sample data structure
  const sampleData = {
    name: 'John Doe',
    age: 30,
    city: 'New York'
  };

  // Insert the sample data into the database
  db.insert(sampleData, (err, newDoc) => {
    if (err) {
      console.error('Error inserting document:', err);
    } else {
      console.log('New document inserted with ID:', newDoc._id);

      // Find and print all documents in the database
      db.find({}, (err, docs) => {
        if (err) {
          console.error('Error finding documents:', err);
        } else {
          console.log('All documents:', docs);
        }
      });
    }
  });
});
Copied!
Copied!

All versions