New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

massive

Package Overview
Dependencies
Maintainers
2
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

massive - npm Package Compare versions

Comparing version 6.3.1 to 6.4.0

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

## [6.4.0](https://gitlab.com/dmfay/massive-js/compare/v6.3.1...v6.4.0) (2020-05-06)
### Features
* text search parsers ([d454d02](https://gitlab.com/dmfay/massive-js/commit/d454d02440170deb34453530454381bda82ed807))
### [6.3.1](https://gitlab.com/dmfay/massive-js/compare/v6.3.0...v6.3.1) (2020-05-04)

@@ -7,0 +14,0 @@

72

lib/readable.js

@@ -165,26 +165,46 @@ 'use strict';

* @param {Object} [options] - {@link https://massivejs.org/docs/options-objects|Select options}.
* @param {Boolean} doDocumentProcessing - True to process results as documents.
* @return {Promise} An array containing any query results.
*/
Readable.prototype.search = function (plan, options = {}) {
if (!plan.fields || !plan.term) {
return this.db.$p.reject(new Error('Need fields as an array and a term string'));
Readable.prototype.search = function (plan, options = {}, doDocumentProcessing = false) {
if (!plan.fields && !plan.tsv) {
return this.db.$p.reject(new Error('Plan must contain a fields array or tsv string'));
} else if (!plan.term) {
return this.db.$p.reject(new Error('Plan must contain a term string'));
}
let tsv;
if (!plan.tsv) {
if (plan.fields.length === 1) {
plan.to_tsv = plan.fields[0];
if (plan.fields.length === 1) {
tsv = plan.fields[0];
if (tsv.indexOf('>>') === -1) {
tsv = quote(tsv); // just a column, quote it to preserve casing
if (plan.to_tsv.indexOf('>>') === -1) {
plan.to_tsv = quote(plan.to_tsv); // just a column, quote it to preserve casing
}
} else {
plan.to_tsv = `concat(${plan.fields.join(", ' ', ")})`; // eslint-disable-line quotes
}
} else {
tsv = `concat(${plan.fields.join(", ' ', ")})`; // eslint-disable-line quotes
}
if (plan.to_tsv) {
plan.tsv = `to_tsvector(${plan.to_tsv})`;
}
switch (plan.parser) {
case 'plain': plan.parser = 'plainto_tsquery'; break;
case 'phrase': plan.parser = 'phraseto_tsquery'; break;
case 'websearch': plan.parser = 'websearch_to_tsquery'; break;
default: plan.parser = 'to_tsquery'; break;
}
const criteria = {
conditions: `to_tsvector(${tsv}) @@ to_tsquery($1)`,
conditions: `${plan.tsv} @@ ${plan.parser}($1)`,
params: [plan.term],
where: plan.where
where: plan.where,
isDocument: options.document
};
if (doDocumentProcessing) {
options.document = true;
}
const query = new Select(this, criteria, options);

@@ -206,33 +226,11 @@

Readable.prototype.searchDoc = function (plan, options = {}) {
if (!plan.term) {
return this.db.$p.reject(new Error('Need fields as an array and a term string'));
}
let tsv;
// TODO 'where' functionality might be better at processing search params for JSON etc
if (!plan.fields) {
tsv = 'search';
} else if (plan.fields.length === 1) {
tsv = `to_tsvector(body ->> '${plan.fields[0]}')`;
plan.tsv = 'search';
} else {
const formattedKeys = plan.fields.map(key => {
plan.fields = plan.fields.map(key => {
return `(body ->> '${key}')`;
});
tsv = `to_tsvector(concat(${formattedKeys.join(", ' ',")}))`; // eslint-disable-line quotes
}
const criteria = {
conditions: `${tsv} @@ to_tsquery($1)`,
params: [plan.term],
where: plan.where,
isDocument: options.document
};
options.document = true; // ensure document result handling activates
const query = new Select(this, criteria, options);
return this.db.query(query);
return this.search(plan, options, true);
};

@@ -239,0 +237,0 @@

{
"name": "massive",
"version": "6.3.1",
"version": "6.4.0",
"description": "A small query tool for Postgres that embraces json and makes life simpler",

@@ -5,0 +5,0 @@ "homepage": "https://massivejs.org",

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