Comparing version 4.0.1 to 4.1.0
@@ -10,6 +10,7 @@ #!/usr/bin/env node | ||
const repl = require('repl'); | ||
const pkg = require('../package.json'); | ||
const massive = require('../index'); | ||
program | ||
.version('3.0.0') | ||
.version(pkg.version) | ||
.option('-d, --database [name]', 'Quick connect with just a local database name') | ||
@@ -16,0 +17,0 @@ .option('-c, --connection [string]', 'Provide a full connection string (postgres://user:password@server/db)') |
@@ -48,3 +48,4 @@ # Persistence | ||
name: 'homepage', | ||
version: 1 | ||
version: 1, | ||
priority: 'low' | ||
}, { | ||
@@ -58,2 +59,4 @@ name: 'about us', | ||
Records in the array may omit keys if the database default value is intended; however, fields having `NOT NULL` constraints must be included or the insert will fail. | ||
[Query options](/options) for `INSERT` statements and results processing may be used with `insert`: | ||
@@ -60,0 +63,0 @@ |
'use strict'; | ||
const _ = require('lodash'); | ||
const prepareParams = require('../util/prepare-params'); | ||
@@ -30,6 +31,10 @@ /** | ||
const keys = _.keys(this.records[0]); | ||
const fields = [..._.reduce(this.records, (set, r) => { | ||
_.forEach(_.keys(r), set.add.bind(set)); | ||
this.columns = _.map(keys, key => `"${key}"`); | ||
this.params = _.reduce(this.records, (params, element) => params.concat(keys.map(key => element[key])), []); | ||
return set; | ||
}, new Set())]; | ||
this.columns = fields.map(f => `"${f}"`); | ||
this.params = prepareParams(fields, this.records); | ||
}; | ||
@@ -36,0 +41,0 @@ |
@@ -5,2 +5,3 @@ 'use strict'; | ||
const where = require('./where'); | ||
const prepareParams = require('../util/prepare-params'); | ||
@@ -19,5 +20,4 @@ /** | ||
this.params = []; | ||
this.params = prepareParams(_.keys(changes), [changes]); | ||
this.changes = _.reduce(changes, (acc, value, key) => { | ||
this.params.push(value); | ||
acc.push(`"${key}" = $${++offset}`); | ||
@@ -24,0 +24,0 @@ |
{ | ||
"name": "massive", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"description": "A small query tool for Postgres that embraces json and makes life simpler", | ||
@@ -52,3 +52,3 @@ "homepage": "https://dmfay.github.io/massive-js/", | ||
"mz": "~2.7.0", | ||
"pg-promise": "~6.5.0", | ||
"pg-promise": "~6.7.0", | ||
"pg-query-stream": "~1.0.0" | ||
@@ -61,3 +61,3 @@ }, | ||
"coveralls": "~2.13.1", | ||
"eslint": "~4.6.0", | ||
"eslint": "~4.7.0", | ||
"jsdoc": "^3.5.4", | ||
@@ -64,0 +64,0 @@ "mocha": "~3.5.1", |
@@ -18,2 +18,3 @@ # Massive.js: A Postgres-centric Data Access Tool | ||
* **Document storage**: PostgreSQL's JSONB storage type makes it possible to blend relational and document strategies. Massive offers a robust API to simplify working with documents: objects in, objects out, with document metadata managed for you. | ||
* **Result decomposition**: while Massive does not traverse relationships or build model graphs, the [`decompose` option](https://dmfay.github.io/massive-js/options.html#decomposition-schemas) allows you to map the results of complex views and scripts to nested object trees. | ||
* **Postgres everything**: committing to a single RDBMS allows us to leverage it to the fullest extent possible. Massive supports array fields and operations, JSON storage, foreign tables, and many, many more features found in PostgreSQL but not in other databases. | ||
@@ -86,4 +87,2 @@ | ||
Unlike object/relational mappers, Massive does not traverse relationships or build model trees. Limited support for mapping complex results to an object graph is a potential future consideration, but if you need to correlate data from multiple tables, using a view is recommended. | ||
The introspection process is fast, but not instantaneous, and you don't want to be doing it every time you run another query. Massive is designed to be initialized once, with the instance retained and used throughout the rest of your application. In Express, you can store the connected instance with `app.set` in your entry point and retrieve it with `req.app.get` in your routes; or with koa, using `app.context`. If no such mechanism is available, you can take advantage of Node's module caching to require the object as necessary. | ||
@@ -372,3 +371,3 @@ | ||
Note that this isn't a true upsert. It basically checks the id field, if it exists it will do an `UPDATE` query otherwise it will do an `INSERT` query. If you specify an `id` that isn't in the database nothing will get updated and `null` will be returned. | ||
This is not a true upsert! `saveDoc`, like `save`, determines whether to emit an `INSERT` or an `UPDATE` based on whether the data _you_ pass it contains a primary key. If you are generating primary keys manually, use `insert` instead -- if you specify a value for the primary key, it will execute an `UPDATE` whether or not the row actually exists in the database, and if it does not the result will be `null`. | ||
@@ -375,0 +374,0 @@ ```javascript |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1523498
118
2398
439
+ Addedpg@7.3.0(transitive)
+ Addedpg-pool@2.0.10(transitive)
+ Addedpg-promise@6.7.1(transitive)
+ Addedpg-types@1.12.1(transitive)
- Removedgeneric-pool@2.4.3(transitive)
- Removedobject-assign@4.1.0(transitive)
- Removedpg@6.4.2(transitive)
- Removedpg-int8@1.0.1(transitive)
- Removedpg-pool@1.8.0(transitive)
- Removedpg-promise@6.5.4(transitive)
- Removedpg-types@1.13.0(transitive)
Updatedpg-promise@~6.7.0