@platformatic/sql-mapper
Advanced tools
Comparing version
@@ -205,3 +205,6 @@ 'use strict' | ||
any: 'ANY', | ||
all: 'ALL' | ||
all: 'ALL', | ||
contains: '@>', | ||
contained: '<@', | ||
overlaps: '&&' | ||
} | ||
@@ -239,2 +242,8 @@ | ||
criteria.push(sql`${value[key]} = ALL (${sql.ident(field)})`) | ||
} else if (operator === '@>') { | ||
criteria.push(sql`${sql.ident(field)} @> ${value[key]}`) | ||
} else if (operator === '<@') { | ||
criteria.push(sql`${sql.ident(field)} <@ ${value[key]}`) | ||
} else if (operator === '&&') { | ||
criteria.push(sql`${sql.ident(field)} && ${value[key]}`) | ||
} else { | ||
@@ -256,3 +265,3 @@ throw new Error('Unsupported operator for Array field') | ||
criteria.push(sql`${leftHand} ${like} ${value[key]}`) | ||
} else if (operator === 'ANY' || operator === 'ALL') { | ||
} else if (operator === 'ANY' || operator === 'ALL' || operator === '@>' || operator === '<@' || operator === '&&') { | ||
throw new Error('Unsupported operator for non Array field') | ||
@@ -259,0 +268,0 @@ } else { |
@@ -106,3 +106,23 @@ import { FastifyPluginAsync, FastifyInstance, FastifyReply, FastifyRequest } from 'fastify' | ||
*/ | ||
ilike?: string | ||
ilike?: string, | ||
/** | ||
* All subquery | ||
*/ | ||
all?: string, | ||
/** | ||
* Any subquery | ||
*/ | ||
any?: string | ||
/** | ||
* Contains values | ||
*/ | ||
contains?: any[], | ||
/** | ||
* Contained by values | ||
*/ | ||
contained?: any[], | ||
/** | ||
* Overlaps with values | ||
*/ | ||
overlaps?: any[] | ||
} | ||
@@ -109,0 +129,0 @@ } |
{ | ||
"name": "@platformatic/sql-mapper", | ||
"version": "0.34.1", | ||
"version": "0.35.0", | ||
"description": "A data mapper utility for SQL databases", | ||
@@ -32,3 +32,3 @@ "main": "mapper.js", | ||
"inflected": "^2.1.0", | ||
"@platformatic/types": "0.34.1" | ||
"@platformatic/types": "0.35.0" | ||
}, | ||
@@ -35,0 +35,0 @@ "tsd": { |
@@ -1074,2 +1074,23 @@ 'use strict' | ||
// where contains | ||
same(await generatedTest.find({ | ||
where: { | ||
test: { contains: [4] } | ||
} | ||
}), [{ id: 1, test: [4, 5, 6], checkmark: true }, { id: 2, test: [4], checkmark: true }]) | ||
// where contained | ||
same(await generatedTest.find({ | ||
where: { | ||
test: { contained: [4, 5, 6] } | ||
} | ||
}), [{ id: 1, test: [4, 5, 6], checkmark: true }, { id: 2, test: [4], checkmark: true }]) | ||
// where overlaps | ||
same(await generatedTest.find({ | ||
where: { | ||
test: { overlaps: [4] } | ||
} | ||
}), [{ id: 1, test: [4, 5, 6], checkmark: true }, { id: 2, test: [4], checkmark: true }]) | ||
// where eq | ||
@@ -1076,0 +1097,0 @@ await rejects(generatedTest.find({ |
174179
0.78%5526
0.86%+ Added
- Removed
Updated