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

iotql

v3.0.1

Published

IoTQL - SQL-like query language for the IoT

Downloads

12

Readme

iotdb-iotql

IoTQL - an SQL-like language for the IoT.

About

Note that we're likely going to depreciate all of this except for the CREATE MODEL call. Why? Because it's starting to look like Apache Drill may be a better solution.

What is it?

IoTQL is an SQL-like language for the IoT. It allows you to query Things, change their state, and define actions to happen in the future. It also allows you to write Models for Things.

Here's a few example queries - see below and the docs folder for a lot more:

-- see everything
SELECT id, state:*, meta:*;
-- set the temperature in the basement
SET state:temperature = 20°C WHERE meta:zone & "Basement";
-- set the color of Hue lights
SET state:color = "#FF9999" WHERE meta:model-id = "hue-light";

It's written to work with HomeStar / IOTDB but is flexible enough to plug into almost any projects that can present a simple Transporter API.

Installation

Then:

$ npm install -g homestar    ## may require sudo
$ homestar install iotql 

Use

Basic pattern:

$ homestar iotql

With Sample Data

IoTQL ships with a (very small) data set for testing

$ homestar iotql --samples
>>> SELECT id, meta:*;

With IOTDB / HomeStar

Make sure you've installed and set up HomeStar, and are in the proper folder - usually your home directory. Then just do:

$ homestar iotql 

Models

All Models in IOTDB are now written using IoTQL. These Models are compiled to JSON-LD for actual usage. You can see examples here:

Library Version

Installation

To embed IoTQL in your projects, do:

$ homestar install iotql

You can use npm instead of homestar if you're not using HomeStar.

Usage

See the docs folder for more documentation. There's also a ton of examples in samples.

In Node.JS

Here's how you use IoTQL in your project

var iotql = require('iotql')
var paramd = {};
iotql.connect(paramd, function(error, db) {
	
);

With Transporter

Not implemented yet

var transporter = ...;
transport.list({
	query: "state:sensor.temperature°C > 25",
}, function(d) {
	if (d.query) {
	}
});

Transporters do not need to support queries. Transporters that do support query will always set d.query to true when a query statement is used.

Syntax / Examples

Get Everything

SELECT id, meta:*, meta:*;

Turn on everything

SET state:on = true

Sight lights to yellow

SET state:color = "yellow" WHERE meta:facet & facets.lighting;

Set the temperature in the basement - in Celsius

SET state:temperature = 20°C WHERE meta:zone & "Basement"

What's the temperature - in Fahrenheit

SELECT units(state:sensor.temperature, °F)

or (more flexible, but unwieldy)

SELECT units(state:sensor.temperature,
             units:temperature.imperial.fahrenheit)

Development

Test Cases

Running

This isn't quite finished yet, but you can do

$ node tools/RunSamples --all

The samples are in samples. The Things it runs against are in samples/things. How that's structured should be fairly obvious.

Writing expected results

$ node tools/RunSamples --all --write

Testing against expected results

$ node tools/RunSamples --all --test

This can also be done by

$ npm test

Compile the Grammar

to compile the grammar, you need to do this

$ ( cd ./grammar; jison grammar.jison )

More Documentation