Get started with lokijs CDN

MIT licensed

Lokijs is a lightweight, in-memory JSON indexing and searching library for JS applications.

Tags:
  • javascript
  • document-oriented
  • mmdb
  • json
  • nosql
  • lokijs
  • in-memory

Stable version

Copied!

How to start using lokijs CDN


<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.cdnhub.io/lokijs/1.5.12/lokijs.min.js"></script>
  <title>Get started with lokijs CDN - cdnhub.io</title>
</head>
<body>
  <script>
    // Initialize a new database instance
    const db = new lokijs('myDatabase.json');

    // Define a collection in the database
    const collection = db.addCollection({ name: 'users', unique: true });

    // Insert some documents into the collection
    collection.insert({ name: 'Alice', age: 25 });
    collection.insert({ name: 'Bob', age: 30 });

    // Query the collection for documents where age is greater than 25
    const query = { age: { $gt: 25 } };
    const results = collection.find(query);

    // Log the results to the console
    console.log(results);

    // Save the database to a file
    db.save();
  </script>
</body>
</html>
Copied!
Copied!

All versions