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

nodenamo-query-parser

v1.2.0

Published

A query parser for nodenamo

Downloads

4

Readme

nodenamo-query-parser

Nodenamo Query Language Parser

Usage

Example

import {parse} from 'nodenamo-query-parser'

let statement = parse('FIND * FROM users WHERE department = "IT" FILTER enabled = true ORDER ASC LIMIT 10')

console.log(statement) 

Output

{
  type: 'find',
  projections: undefined,
  from: 'users',
  using: undefined,
  where: {
    expressionAttributeNames: { '#department': 'department' },
    expressionAttributeValues: { ':department': 'IT' },
    keyConditions: '#department = :department'
  },
  filter: {
    expressionAttributeNames: { '#enabled': 'enabled' },
    expressionAttributeValues: { ':enabled': true },
    filterExpression: '#enabled = :enabled'
  },
  resume: undefined,
  order: true,
  limit: 10,
  stronglyConsistent: undefined
}

Nodenamo Query Language

Table of Content

IMPORT statement

Syntax

IMPORT class FROM "path" IMPORT class AS alias FROM "path" IMPORT {class} FROM "path" IMPORT {class as alias} FROM "path"

where:

  • class is the exported class decorated with nodenamo's @DBTable

  • alias is an alias to be referenced to the imported class from subsequent statements.

  • path is the path to the file or a package containing the class to import.

Example

IMPORT usersTable as users FROM "./usersTable.ts"

Output

{
  type: 'import',
  entity: [ { name: 'usersTable', as: 'users', default: true } ],
  from: './usersTable.ts'
}

INSERT Statement

Syntax

INSERT jsonObject INTO table WHERE expression

Example

INSERT {id:2,title:"some thing",price:21,status:true} INTO books WHERE attribute_not_exists(id)

Output

{
  type: 'insert',
  object: { id: 2, title: 'some thing', price: 21, status: true },
  into: 'books',
  where: {
    expressionAttributeNames: { '#id': 'id' },
    expressionAttributeValues: {},
    conditionExpression: 'attribute_not_exists(#id)'
  }
}

GET Statement

Syntax

GET id FROM table STRONGLY CONSISTENT

Example

GET 42 FROM users STRONGLY CONSISTENT

Output

{
  type: 'get', 
  id: 42, 
  from: 'users', 
  stronglyConsistent: true
}

LIST Statement

Syntax

LIST projections FROM table USING indexName BY hashRange FILTER filterExpressions RESUME "lastEvaluatedKey" ORDER order LIMIT number STRONGLY CONSISTENT

where:

  • projections is a list of properties to return. Use * to return all properties.
  • indexName is the name of a GSI.
  • hashRange is a value to search against a hash property. It can be optionally followed by a comma and a value to search against a range property.
  • order is ASC or DESC
  • strongly consistent can be used to request a consistent read.

Example

LIST * FROM users BY "name" , "timestamp" FILTER email = "[email protected]" ORDER asc LIMIT 10 STRONGLY CONSISTENT

Output

{
  type: 'list',
  projections: undefined,
  from: 'users',
  using: undefined,
  by: { hash: 'name', range: 'timestamp' },
  filter: {
    expressionAttributeNames: { '#email': 'email' },
    expressionAttributeValues: { ':email': '[email protected]' },
    filterExpression: '#email = :email'
  },
  resume: undefined,
  order: true,
  limit: 10,
  stronglyConsistent: true
}

FIND Statement

Syntax

FIND projections FROM table USING indexName WHERE keyConditions FILTER filterExpressions RESUME "lastEvaluatedKey" ORDER order LIMIT number STRONGLY CONSISTENT

where:

  • projections is a list of properties to return. Use * to return all properties.
  • indexName is the name of a GSI.
  • order is ASC or DESC
  • strongly consistent can be used to request a consistent read.

Example

FIND id, name, email FROM users USING users-gsi WHERE name = "some one" FILTER email = "[email protected]" resume "token" ORDER desc LIMIT 2 STRONGLY CONSISTENT

Output

{
  type: 'find',
  projections: [ 'id', 'name', 'email' ],
  from: 'users',
  using: 'users-gsi',
  where: {
    expressionAttributeNames: { '#name': 'name' },
    expressionAttributeValues: { ':name': 'some one' },
    keyConditions: '#name = :name'
  },
  filter: {
    expressionAttributeNames: { '#email': 'email' },
    expressionAttributeValues: { ':email': '[email protected]' },
    filterExpression: '#email = :email'
  },
  resume: 'token',
  order: false,
  limit: 2,
  stronglyConsistent: true
}

UPDATE Statement

Syntax

UPDATE jsonObject FROM table WHERE conditionExpression WITH VERSION CHECK

where:

  • WITH VERSION CHECK can be used to request a version check.

Example

UPDATE {id:1,name:"new name"} FROM users WHERE attribute_not_exists(id) WITH VERSION CHECK

Output

{
  type: 'update',
  object: { id: 1, name: 'new name' },
  from: 'users',
  where: {
    expressionAttributeNames: { '#id': 'id' },
    expressionAttributeValues: {},
    conditionExpression: 'attribute_not_exists(#id)'
  },
  versionCheck: true
}

ON Statement

Syntax

ON id FROM table SETsetExpression ADD addExpression DELETE deleteExpression REMOVE removeExpression conditionExpression WITH VERSION CHECK

where:

  • WITH VERSION CHECK can be used to request a version check.

Example

ON 42 FROM users SET lastViewed = "today" ADD count 1 WHERE published = true WITH VERSION CHECK

Output

{
  type: 'on',
  id: 42,
  from: 'users',
  set: {
    setExpressions: [ '#lastViewed___1 = :lastViewed___1' ],
    expressionAttributeNames: { '#lastViewed___1': 'lastViewed' },
    expressionAttributeValues: { ':lastViewed___1': 'today' }
  },
  add: {
    addExpressions: [ '#count___2 :count___2' ],
    expressionAttributeNames: { '#count___2': 'count' },
    expressionAttributeValues: { ':count___2': 1 }
  },
  remove: undefined,
  delete: undefined,
  where: {
    expressionAttributeNames: { '#published': 'published' },
    expressionAttributeValues: { ':published': true },
    conditionExpression: '#published = :published'
  },
  versionCheck: true
}

DELETE Statement

Syntax

DELETE id FROM table WHERE conditionExpression

Example

DELETE 42 FROM books WHERE deleted <> true

Output

{
  type: 'delete',
  id: 42,
  from: 'books',
  where: {
    expression: '#deleted <> :deleted',
    expressionAttributeNames: { '#deleted': 'deleted' },
    expressionAttributeValues: { ':deleted': true }
  }
}

UNLOAD TABLE Statement

Syntax

UNLOAD TABLE name

where:

  • name is the imported class name or its alias.

Example

UNLOAD TABLE users

Output

{ 
  type: 'unload_table', 
  name: 'users' 
}

CREATE TABLE Statement

Syntax

CREATE TABLE FOR name WITH CAPACITY OF readCapacityNumber, writeCapacityNumber

where:

  • name is the imported class name or its alias.
  • readCapacityNumber is the desired read capacity for the table.
  • writeCapacityNumber is the desired write capacity for the table.

Example

CREATE TABLE FOR users WITH CAPACITY OF 123, 456

Output

{
  type: 'create_table',
  for: 'users',
  withCapacityOf: { readCapacity: 123, writeCapacity: 456 }
}

DELETE TABLE Statement

Syntax

DELETE TABLE FOR name

where:

  • name is the imported class name or its alias.

Example

DELETE TABLE FOR users

Output

{
  type: 'delete_table',
  for: 'users'
}

SHOW TABLES Statement

Syntax

SHOW TABLES

Example

SHOW TABLES

Output

{
  type: 'show_tables',
}

EXPLAIN Statement

Syntax

Explain statement

where:

  • statement is one of nodenamo query language stattements.

Example

EXPLAIN INSERT {id:1,name:"some one"} INTO users

Output

{
  type: 'explain',
  statement: {
    type: 'insert',
    object: { id: 1, name: 'some one' },
    into: 'users',
    where: undefined
  }
}

DESCRIBE Statement

Syntax

Describe name

where:

  • name is the imported class name or its alias.

Example

DESCRIBE users

Output

{
  type: 'describe',
  name: 'users'
}