0.2.0 • Published 2 years ago

sqlaudit v0.2.0

Weekly downloads
18
License
-
Repository
-
Last release
2 years ago

NodeJS SQL Audit

This is a module that accepts a specific language that you can use to simplify auditing of SQL data.

Example

const sqlaudit = require("sqlaudit");
const audit    = new sqlaudit({
	db : "mysql://user:password@host/database",
});

// there's also an audit.runFile(filename, next)
audit.runCode(`
	for users[age < 18] {
		// users under age must have no logins
		total_logins = 0
		total_logins = user_logins[user_id = id].count()
	}
`, (err, result) => {
	if (err) throw err;

	console.log(result);
});

Language

Query

A query is the most important component of the language. It is strongly based on CSS query syntax.

table[prop1 > value1, prop2 != value2].sum(value3)

This basically selects from table table based on those 2 conditions (prop1 and prop2) and agregates using SUM() based on value3.

In this specific case, we're selecting a single value. You can also select a row.

table[prop1 = value]:order(-prop2):first()

This selects from table table order descending (that's what the minus sign is for) by prop2 and returns the first row (this is the same as :limit(1)).

You can also use this query and then select a specific property:

table[prop1 = value]:order(-prop2):first().prop2

COMMENT

// comment

FOR (loop)

for <expression> {
	...
}

IF (condition)

if <statement> {
	...
}
0.2.0

2 years ago

0.1.0

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago