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

orientx

v0.3.2

Published

An OrientDB development tools

Downloads

31

Readme

orientx

An OrientDB development tools

Features

  • Create one or more databases with one command!
  • Use multiple schema files to create a database
  • You can use most of the OrientDB features, e.g. cluster, class, edge class, property, index, sequence, function and schedule
  • You can create and manage migrations using orientjs
  • Beautiful and meaningful logs and errors
  • It's easy to use

orientx-logs

NOTE: Only works in node@>=8.3.0 (or node@>=8.0.0 with --harmony flag) because of "async/await" and "object spread properties" support

Index

Install

You can install it in your project:

$ npm i orientx
# or
$ yarn add orientx

and use it in scripts property of the package.json, like this:

{
  "scripts": {
    "create-db": "orientx db:create ./schema.yaml",
    "drop-db": "orientx db:drop MyDatabase",
    "migrate": "orientx migrate"
  }
}

or install it globally:

$ npm i -g orientx
# or
$ yarn global add orientx

and use it like this:

$ orientx --help

Usage

Usage:  <command> [options]

Options:

  -V, --version              output the version number
  -c, --config <config>      orientx configuration file
  --odb-host <host>          orientdb server host
  --odb-port <port>          orientdb server port
  --odb-username <username>  orientdb server username
  --odb-password <password>  orientdb server password
  -h, --help                 output usage information


Commands:

  db:create|dbc <schema>  create database structure from one or more schemas
  db:drop|dbd <name...>   drop one or more database
  migrate|m [options]     database migration

OrientDB server configuration

By default orientx uses the following configuration to connect to the OrientDB server:

{
  "host": "localhost",
  "port": 2424,
  "username": "root"
}

You can set OrientDB server password or other configurations in following ways:

1. CLI flags

  --odb-host <host>          orientdb server host
  --odb-port <port>          orientdb server port
  --odb-username <username>  orientdb server username
  --odb-password <password>  orientdb server password

2. Environment variables

  • ORIENTDB_HOST
  • ORIENTDB_PORT
  • ORIENTDB_USERNAME
  • ORIENTDB_PASSWORD

3. orientx configuration file

If you installed orientx in your project, you can create an .orientxrc.yaml file and place it in your project's root directory to be automatically loaded (.orientxrc.json and .orientxrc.js are also supported)

Also, you can set orientx configuration file manually using --config option:

  -c, --config <config>      orientx configuration file

Sample configuration file:

server:                   # Server config
  host: localhost
  port: 2424
  username: root
  password: xxxxx

db:                       # Default database configs for all schemas
  name: MyDatabase        # [optional]
  type: graph             # [optional]
  storage: plocal         # [optional]
  lightweightEdges: true  # [optional]

Create a database

You can use the following command to create a database from a schema file (supported formats: .yaml, .yml, .json or .js)

$ orientx db:create ./schema.yaml
# or
$ orientx dbc ./schema-*

or you can use node-glob pattern (it must have quotation marks)

$ orientx db:create './**/schema-@(db1|db2).{yaml,json}'

Schema

---
# Database config
db:
  name: MyDatabase
  type: graph             # [optional]
  storage: plocal         # [optional]
  username: admin         # [optional]
  password: admin         # [optional]
  lightweightEdges: true  # [optional]

# Sequence
# https://orientdb.com/docs/last/SQL-Create-Sequence.html
sequence:
  id: ordered
  foobarId:
    name: foobarId  # [optional, autoPick]
    type: cached
    start: 1000     # [optional]
    incr: 10        # [optional]
    cache: 5        # [optional]

# Function
# https://orientdb.com/docs/last/SQL-Create-Function.html
function:
  fooFn: print('fooFn')
  barFn:
    name: barFn           # [optional, autoPick]
    code: print('barFn')
    parameters: [aa, bb]  # [optional]
    idempotent: true      # [optional]
    language: sql         # [optional]

# Schedule
# https://orientdb.com/docs/last/Scheduler.html
schedule:
  cleanup:
    name: cleanup                          # [optional, autoPick]
    rule: 0/1 * * * * ?
    function: barFn
    arguments:                             # [optional]
      a: 1
      b: 2
    startTime: '2017-02-05T23:59:20.252Z'  # [optional] Parse with `new Date()`

# Cluster
# https://orientdb.com/docs/last/SQL-Create-Cluster.html
cluster:
  us: null
  asia: 201
  europe:
    name: europe
    id: 202

# Class
class:
  User:
    # https://orientdb.com/docs/last/SQL-Create-Class.html
    name: User             # [optional, autoPick]
    superClass: V          # [optional]
    abstract: false        # [optional]
    cluster: 201,202       # [optional]
    
    # Class properties
    # https://orientdb.com/docs/last/SQL-Create-Property.html
    props:
      id:
        type: Integer
        default: '"sequence(''id'').next()"'  # [optional]

      name: String
      surname: String
      
      username:
        type: String
        mandatory: true        # [optional]
        readonly: true         # [optional]
        regexp: '"[a-z.-_]+"'  # [optional]
        min: 3                 # [optional]
        max: 40                # [optional]

      createdAt: Datetime

      friend:
        type: Link
        linkedClass: User     # [optional]
        notNull: true         # [optional]

      foobar:
        type: EmbeddedMap
        linkedType: Integer   # [optional]

    # Class index
    # https://orientdb.com/docs/last/SQL-Create-Index.html
    index:
      User.id: UNIQUE_HASH_INDEX

      User.nameAndSurname:
        name: User.nameAndSurname     # [optional]
        type: FULLTEXT ENGINE LUCENE
        class: User                   # [optional, autoPick]
        properties: [name, surname]   # [optional, autoPick] `autoPick` only works when
                                      #   the index name is like `[CLASS_NAME].[PROPERTY_NAME]`
# Edge class (same as class)
edge:
  following: E
    
  follow:
    name: follow          # [optional, autoPick]
    superClass: E         # [optional, autoPick]

    # Edge class properties (same as class properties)
    props:                # [optional]
      out:
        type: Link
        linkedType: User  # [optional]
      in:
        type: Link
        linkedType: User  # [optional]
      at: Datetime

# Global index (same as class index)
# https://orientdb.com/docs/last/SQL-Create-Index.html
index:
  User.createdAt: NOTUNIQUE

---
# You can have multiple schema in one yaml file

# Database config
db:
  name: MyDatabase2

Drop a database

You can drop the database for development purpose using following command:

$ orientx db:drop MyDatabase
# or
$ orientx dbd MyDatabase MyDatabase2

Migration

The migrate command is just a proxy to the node-migrate, see the documentation here

Difference:

  • New template file that imports orientx/db and uses async/await syntax
  • orientx/db is a module that uses the server configuration that you set in the previous sections and exports pre-configured orientjs instance. also, it exports getServer() and orientjs

Template file:

const db = require('orientx/db')('DB_NAME');

exports.up = async () => {
  // await db.query(...);
};

exports.down = async () => {
  // await db.query(...);
};

Credit

node-migrate by @tj, used in migrate command

License

MIT © 2017 Rasool Dastoori