mlaanderson / database-js

Common Database Interface for Node
MIT License
74 stars 16 forks source link

Add support to TXT files #16

Open thiagodp opened 6 years ago

thiagodp commented 6 years ago

Proposal

database-js-txt

Virtual Columns

Text files could have these virtual columns:

  1. line (any line of the file)
  2. line_number

Examples:

# Line starting with Hello
SELECT `line_number`, `line` WHERE `line` LIKE "Hello%"

# First line in the file
SELECT `line` WHERE `line_number` = 1

# Number of lines in the file
SELECT COUNT( `line` )

# Number of lines in the file, different way
SELECT MAX( `line_number` )

# Last line in the file
SELECT `line` WHERE `line_number` = COUNT( `line` )

# Content from some lines
SELECT `line` WHERE `line_number` BETWEEN 5 AND 10

# Content from some lines, different way (needed?)
SELECT `line` OFFSET 5 LIMIT 5

Basic Operators

=, <>, >, >=, <, <=, LIKE, NOT, AND, OR, BETWEEN

Basic Constructions

WHERE, ORDER BY

Basic Functions

COUNT, MAX

Expected future enhancements