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

lunardb-js

v2.1.2

Published

LunarDB JavaScript API

Downloads

4

Readme

🌙 LunarDB-JS

LunarDB-JS is a JavaScript API designed as interface for LunarDB Server, a powerful C++ database management system.

This API allows seamless communication between Node.js backend servers and the LunarDB Server using WebSocket connections, facilitating robust and scalable database solutions for web applications and services.

For more informations on LunarDB C++ Server, visit https://github.com/TheAncientOwl/lunardb.

✨ Features

  • 🔗 WebSocket Integration: Leverages WebSocket connections for real-time communication with the LunarDB server.
  • 🌟 Simple API: Provides an easy-to-use interface for sending queries to the LunarDB server.
  • ⚡ Asynchronous Operations: Supports asynchronous operations for efficient handling of database queries.
  • 📈 Scalability: Designed to handle high volumes of database requests, making it suitable for large-scale applications.

📦 Installation

Install LunarDB-JS via npm:

$ npm install lunardb-js

🚀 Usage

For more examples you can take a look at integration tests located at ./test/integration/*js. Each one is a good example on how to send queries and use the results.

Also, you may want to take a look at AstroHuddle, an usage example of this API. The project can be found here.

import { LunarDB, QueryBuilders } from 'lunardb-js';

const ldb = new LunarDB('127.0.0.1', 8083);

ldb.addOnConnectListener(() => {
    const querries = [ ... ]; // see next section regarding queries

    try {
        for (const query of querries) {
            const server_result = await ldb.query(query);
            console.log(server_result);
        }
    } catch (err) {
        console.error(err);
    }
});

ldb.connect();

📚 Queries API

Notes

  • .build() generates a valid string that can be run by LunarDB server.
  • When sending the query via LunarDB::query(...) calling .build() on the querry object is not necessary. The method is smart enough to call it on its own if it identifies a query object.
  • More than that, if you don't want to use the QueryBuilder API, you can pass raw strings representing valid MoonlightQL queries. More details on Moonlight can be found here.
new Database().isCreate().name('<database-name>').build();
new Database().isUse().name('<database-name>').build();
new Database().isDrop().name('<database-name>').build();
new Database().isBackup('path/to/backup/directory').name('<database-name>').build();

new User().create().username('<username>').password('<password>').build();
new User().remove().username('<username>').password('<password>').build();

new Grant()
    .toUser('<username>')
    .onCollection('<collection-name>')
    .permission('<permission01>')
    .permission('<permission02>')
    ...
    .permission('<permission-n>')
    .build();

new Revoke()
    .fromUser('<username>')
    .onCollection('<collection-name>')
    .permission('<permission01>')
    .permission('<permission02>')
    ...
    .permission('<permission-n>')
    .build();

new Schema()
    .name('<schema-name>')
    .inherits('<schema-name01>')
    .inherits('<schema-name02>')
    ...
    .inherits('<schema-name-n>')
    .addField({name: '<field-name01>', type: '<field-type01>'})
    .addField({name: '<field-name02>', type: '<field-type02>'})
    ...
    .addField({name: '<field-name-n>', type: '<field-type-n>'})
    .build();

new Create().isTable().name('<collection-name>').schema('<schema-name>').build();
new Create().isDocument().name('<collection-name>').schema('<schema-name>').build();

new Rebind()
    .current('<collection-name::field-name>')
    .to('<rebind-collection-name')
    .clean(true|false)
    .build();

new Drop()
    .collection('<collection-name>')
    .cascade(true|false)
    .build();

new Insert()
    .into('<collection-name>')
    .addObject({/* JavaScript object 01 */})
    .addObject({/* JavaScript object 02 */})
    ...
    .addObject({/* JavaScript object -n */})
    .build();

new Truncate().collection('<collection-name>').build();

new Select()
    .from('<collection-name>')
    .where('<where-clause>')
    .addField('field01')
    .addField('field02')
    ...
    .addField('field-n')
    .build();

new Delete()
    .from('<collection-name>')
    .where('<where-clause>')
    .build();

new Update()
    .structure('<collection-name>')
    .where('<where-clause>')
    .addModify({ field: '<field-name01>', expression: '<expression01>' })
    .addModify({ field: '<field-name02>', expression: '<expression02>' })
    ...
    .addModify({ field: '<field-name-n>', expression: '<expression-n>' })
    .build();

new Commit().build();
new SavePoint().hash('<hash>').build();
new Rollback().hash('<hash>').build();

📄 License

LunarDB-JS is licensed under the MIT License. See the LICENSE file for more information.