Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
A node.js client library for LogicBlox. Allows you to connect to LogicBlox using pure JavaScript running in node.js.
It is the product of the LogicBlox Hackathon '13 and written by Zef Hemel. A 5 minute screencast explaining it can be seen here.
We now position LogicBlox as a database. Typically, a database is not enough to build complete applications. You typically have an application server of some kind that talks to the database and executes queries. On the Java platform you have JDBC for SQL databases. I already built a Clojure connector for LogicBlox before, so this time I thought I'd try building one for node.js.
The cool thing about node.js is
The project contains a Vagrantfile:
$ vagrant up
Once done (this will take a while), login:
$ vagrant ssh
and then run npm install
to intall dependencies:
$ npm install
To run the tests (in tests
):
$ npm test
Import the module:
var lbConnect = require("lbc");
Connect to LB:
lbConnect(function(err, conn) {
// Your code here
// Close connection
conn.close();
});
Disconnect:
conn.close(function(err) {
...
});
Add a block:
conn.addBlock("myworkspace", "person(x) -> string(x).", function(err) {
...
});
Execute a block:
conn.exec("myworkspace", "+person(\"Zef\").", function(err) {
...
});
Query a predicate:
conn.query("myworkspace", "person", function(err, results) {
console.log(results);
});
Execute a query:
conn.query("myworkspace", "_(p) <- person(p).", function(err, results) {
console.log(results);
});
Create a workspace:
conn.createWorkspace("myworkspace", function(err) {
...
});
Export a workspace:
conn.exportWorkspace("myworkspace", "/tmp/myws", function(err) {
...
});
Import a workspace:
conn.importWorkspace("myworkspace2", "/tmp/myws", function(err) {
...
});
Remove a workspace:
conn.removeWorkspace("myworkspace2", function(err) {
...
});
The sample/
directory contains two samples:
replserver.js
: a server that could be used as a more secure connectblox implementation (used now at https://repl.logicblox.com).lb_api_server.js
which is described in the next section.Most, if not practically all databases that I know of have some sort of authentication and authorization system. LogicBlox does not. In fact, support for connecting to a LB database from another system is very limited.
The LB API server (samples/lb_api_server.js
) exposes a LogicBlox server via a HTTP RESTful API and adds support for multiple users and authorization of users for specific workspaces, so you can create a user (as an admin) that can query a workspace, but not run 'exec' queries, or have access to other workspaces on the same server.
Documentation is limited due to time constraints, but the curl commands at the
top of lb_api_server.js
should help understanding the idea.
The users and their permissions are stored in a users
workspace which is automatically created when the server is
first started (and it does not already exist). The schema
for this can be found under sample/api_server_schema.logic
, as well as the initial data (for the admin
user) in sample/api_server_init.logic
.
FAQs
node-lbc ========
We found that lbc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.