Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@koopjs/winnow

Package Overview
Dependencies
Maintainers
7
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@koopjs/winnow - npm Package Compare versions

Comparing version 4.0.5 to 4.1.0

src/normalize-query-options/object-ids.js

2

package.json
{
"name": "@koopjs/winnow",
"version": "4.0.5",
"version": "4.1.0",
"description": "Apply sql-like filters to GeoJSON",

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

@@ -19,9 +19,15 @@ const _ = require('lodash');

function extractIdField ({ idField, fields } = {}, feature = {}) {
if (idField) return idField;
if (idField) {
return idField;
}
// metadata.idField is not set, but fields array includes OBJECTID, use that as idField
if (_.find(fields, { name: 'OBJECTID' })) return 'OBJECTID';
if (_.find(fields, { name: 'OBJECTID' })) {
return 'OBJECTID';
}
const properties = feature.properties || feature.attributes;
if (_.has(properties, 'OBJECTID') && properties.OBJECTID !== null) return 'OBJECTID';
if (_.has(properties, 'OBJECTID') && properties.OBJECTID !== null) {
return 'OBJECTID';
}

@@ -28,0 +34,0 @@ return null;

@@ -17,2 +17,3 @@ const _ = require('lodash');

const normalizeOffset = require('./offset');
const normalizeObjectIds = require('./object-ids');

@@ -38,3 +39,4 @@ function normalizeQueryOptions (options, features) {

inputCrs: normalizeSourceDataSpatialReference(options),
classification: normalizeClassification(options)
classification: normalizeClassification(options),
objectIds: normalizeObjectIds(options.objectIds)
});

@@ -41,0 +43,0 @@ normalizedOptions.offset = normalizeOffset(normalizedOptions);

@@ -8,3 +8,3 @@ const SqlWhereBuilder = require('./where-builder');

const select = createSelectSql(options);
const where = options.where || options.geometry ? ` WHERE ${SqlWhereBuilder.create(options)}` : '';
const where = options.objectIds || options.where || options.geometry ? ` WHERE ${SqlWhereBuilder.create(options)}` : '';
const orderBy = createOrderByClause(options);

@@ -11,0 +11,0 @@ const groupBy = createGroupByClause(options);

@@ -112,2 +112,6 @@ const { InvalidWhereParameterError } = require('../../errors');

toJsonSQL () {
if (this.#options.objectIds && this.#options.idField) {
this.#addObjectIdsFilter();
}
if (!this.#where) {

@@ -121,2 +125,12 @@ return this;

#addObjectIdsFilter() {
const objectIdFilter = `${this.#options.idField} IN (${this.#options.objectIds.join(',')})`;
if (this.#where) {
this.#where = `${this.#where} AND ${objectIdFilter}`;
return;
}
this.#where = objectIdFilter;
}
/**

@@ -123,0 +137,0 @@ * if the where clause includes OBJECTID predicate and there is no "idField" option

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