notrab / sqlite-statement-type

isSelect or not

Home Page:https://www.npmjs.com/package/sqlite-statement-type

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sqlite-statement-type

This is a set of functions that let you test is the SQLite statement is a certain operation.

This is useful when you want to know if a statement is a SELECT, INSERT, UPDATE, DELETE, CREATE TABLE, etc.

The next steps for this library would be to add support for checking recursive statements.

Install

npm install sqlite-statement-type

Quickstart

import { isSelect } from "sqlite-statement-type";

const statement = "SELECT * FROM users";

console.log(isSelect(statement)); // true

API Reference

isSelect

import { isSelect } from "sqlite-statement-type";

const statement = "SELECT * FROM table";

const result = isSelect(statement);

isInsert

import { isInsert } from "sqlite-statement-type";

const statement = "INSERT INTO table (column) VALUES ('value')";

const result = isInsert(statement);

isUpdate

import { isUpdate } from "sqlite-statement-type";

const statement = "UPDATE table SET column = 'value'";

const result = isUpdate(statement);

isDelete

import { isDelete } from "sqlite-statement-type";

const statement = "DELETE FROM table";

const result = isDelete(statement);

isCreateTable

import { isCreateTable } from "sqlite-statement-type";

const statement = "CREATE TABLE table (column TEXT)";

const result = isCreateTable(statement);

isAlterTable

import { isAlterTable } from "sqlite-statement-type";

const statement = "ALTER TABLE table ADD COLUMN column TEXT";

const result = isAlterTable(statement);

isDropTable

import { isDropTable } from "sqlite-statement-type";

const statement = "DROP TABLE table";

const result = isDropTable(statement);

isCreateIndex

import { isCreateIndex } from "sqlite-statement-type";

const statement = "CREATE INDEX index ON table (column)";

const result = isCreateIndex(statement);

isDropIndex

import { isDropIndex } from "sqlite-statement-type";

const statement = "DROP INDEX index";

const result = isDropIndex(statement);

isCreateView

import { isCreateView } from "sqlite-statement-type";

const statement = "CREATE VIEW view AS SELECT * FROM table";

const result = isCreateView(statement);

isAlterView

import { isAlterView } from "sqlite-statement-type";

const statement = "ALTER VIEW view AS SELECT * FROM table";

const result = isAlterView(statement);

isDropView

import { isDropView } from "sqlite-statement-type";

const statement = "DROP VIEW view";

const result = isDropView(statement);

isPragma

import { isPragma } from "sqlite-statement-type";

const statement = "PRAGMA table_info(table)";

const result = isPragma(statement);

isBeginTransaction

import { isBeginTransaction } from "sqlite-statement-type";

const statement = "BEGIN TRANSACTION";

const result = isBeginTransaction(statement);

isAttach

import { isAttach } from "sqlite-statement-type";

const statement = "ATTACH DATABASE 'file.db' AS db";

const result = isAttach(statement);

isDetach

import { isDetach } from "sqlite-statement-type";

const statement = "DETACH DATABASE db";

const result = isDetach(statement);

isCreateTrigger

import { isCreateTrigger } from "sqlite-statement-type";

const statement = "CREATE TRIGGER trigger AFTER INSERT ON table BEGIN END";

const result = isCreateTrigger(statement);

isDropTrigger

import { isDropTrigger } from "sqlite-statement-type";

const statement = "DROP TRIGGER trigger";

const result = isDropTrigger(statement);

About

isSelect or not

https://www.npmjs.com/package/sqlite-statement-type


Languages

Language:TypeScript 99.0%Language:JavaScript 1.0%