Socket
Socket
Sign inDemoInstall

orma

Package Overview
Dependencies
Maintainers
2
Versions
233
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

orma - npm Package Compare versions

Comparing version 1.0.29 to 1.0.30

2

build/index.d.ts

@@ -1,2 +0,2 @@

export declare const introspector: (db: string, fn: (s: string[]) => Promise<Record<string, unknown>[][]>) => Promise<import("./introspector/introspector").orma_schema>;
export declare const orma_introspect: (db: string, fn: (s: string[]) => Promise<Record<string, unknown>[][]>) => Promise<import("./introspector/introspector").orma_schema>;
export declare const orma_query: (raw_query: any, orma_schema: any, query_function: (sql_string: string[]) => Promise<Record<string, unknown>[][]>) => Promise<{}>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.orma_query = exports.introspector = void 0;
exports.orma_query = exports.orma_introspect = void 0;
const introspector_1 = require("./introspector/introspector");
const query_1 = require("./query/query");
exports.introspector = introspector_1.introspector;
exports.orma_introspect = introspector_1.orma_introspect;
exports.orma_query = query_1.orma_query;

@@ -117,3 +117,3 @@ /**

export declare const generate_field_schema: (mysql_column: mysql_column) => orma_field_schema;
export declare const introspector: (db: string, fn: (s: string[]) => Promise<Record<string, unknown>[][]>) => Promise<orma_schema>;
export declare const orma_introspect: (db: string, fn: (s: string[]) => Promise<Record<string, unknown>[][]>) => Promise<orma_schema>;
export {};

@@ -7,3 +7,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.introspector = exports.generate_field_schema = exports.generate_database_schema = exports.get_introspect_sqls = void 0;
exports.orma_introspect = exports.generate_field_schema = exports.generate_database_schema = exports.get_introspect_sqls = void 0;
const helpers_1 = require("../helpers/helpers");

@@ -173,3 +173,3 @@ /**

exports.generate_field_schema = generate_field_schema;
const introspector = async (db, fn) => {
const orma_introspect = async (db, fn) => {
const sql_strings = exports.get_introspect_sqls(db);

@@ -186,2 +186,2 @@ // @ts-ignore

};
exports.introspector = introspector;
exports.orma_introspect = orma_introspect;
{
"name": "orma",
"version": "1.0.29",
"version": "1.0.30",
"description": "A declarative relational syncronous orm",

@@ -5,0 +5,0 @@ "main": "build/index.js",

## Orma
Update read format,

@@ -7,7 +8,7 @@ ----------🚧 THIS PROJECT IS A WORK IN PROGRESS 🚧----------

Orma provides introspection, validation, query construction and mutations.
Orma provides introspection, validation, query construction and mutations.
The package uses json format to represent sql queries and mutations.
When the database is instrospected a declarative schema is generated as a json object.
Typescript types are also generated.
Typescript types are also generated.

@@ -25,8 +26,7 @@ The orma schema can be diffed by the user and validated using runtime schema validation functions.

Disadvantages
Supports sql databases only
## Installation
## Installation
```

@@ -37,21 +37,59 @@ npm i orma // Or yarn add orma

## Intospect a mysql database
This is where we describe what introspection means
What is the syntax
What are the limitations
Introspecting the database will produce a json object called the orma schema.
The orma schema describes the table column and foreign key information which
are needed for queries and mutations.
```js
import { ... } from 'orma'
// here is a code snippet
import { orma_introspect } from 'orma'
import mysql from 'mysql2'
// Using a promise pool
const pool = mysql
.createPool({
host: env.host,
port: env.port,
user: env.user,
password: env.password,
database: env.database,
multipleStatements: true
})
.promise()
// Setup a function which given sql strings can return an array of results
const pool_query = async sql_strings => {
const results = await pool
.query(sql_strings.join(';'))
.then(res => (sql_strings.length === 1 ? [res[0]] : res[0]))
return results
}
const orma_schema = await orma_introspect(env.database, pool_query)
// At this point you may diff the json schema if needed and save it for later use.
```
## Construct queries
The query generates nested json by...
Orma queries are json objects. In the following scenario, a nested query is made.
```js
// This is how you construct queries
// This is how you execute queries
const query = {
users: {
id: true,
first_name: true,
last_name: true,
addresses: {
id: true
}
}
}
const results = await orma_query(query, orma_schema, pool_query)
```
## Construct Mutations
Mutation format is the same as from the read uil...
Operations are nested in as meta on each level...
Here is where we explain what recursive op hierarchy alternative to graphql
```js

@@ -58,0 +96,0 @@ // Another snippet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc