Add (not)oneOf filter methods

This commit is contained in:
Mel O'Hagan 2022-06-24 14:41:08 +01:00
parent 848b42dad5
commit 36a59632c4
3 changed files with 46 additions and 25 deletions

View File

@ -14,6 +14,8 @@ export const getValidOperatorsForType = type => {
Op.Like,
Op.Empty,
Op.NotEmpty,
Op.In,
Op.NotIn,
]
const numOps = [
Op.Equals,
@ -91,6 +93,8 @@ export const buildLuceneQuery = filter => {
notEmpty: {},
contains: {},
notContains: {},
oneOf: {},
notOneOf: {},
}
if (Array.isArray(filter)) {
filter.forEach(expression => {
@ -139,7 +143,6 @@ export const buildLuceneQuery = filter => {
}
})
}
return query
}
@ -211,6 +214,16 @@ export const runLuceneQuery = (docs, query) => {
return docValue == null || docValue === ""
})
// Process an includes match (fails if the value is not included)
const oneOf = match("oneOf", (docValue, testValue) => {
return !testValue?.includes(docValue)
})
// Process a not included match (fails if the value is included)
const notOneOf = match("notOneOf", (docValue, testValue) => {
return testValue?.includes(docValue)
})
// Match a document against all criteria
const docMatch = doc => {
return (
@ -220,7 +233,9 @@ export const runLuceneQuery = (docs, query) => {
equalMatch(doc) &&
notEqualMatch(doc) &&
emptyMatch(doc) &&
notEmptyMatch(doc)
notEmptyMatch(doc) &&
oneOf(doc) &&
notOneOf(doc)
)
}

View File

@ -1094,12 +1094,12 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.0.207-alpha.6":
version "1.0.207-alpha.6"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.207-alpha.6.tgz#47fed5cc78686e23951a050479c777673f725c17"
integrity sha512-mB3i9TyNbdlE8TmsAWGXhphwLRlrBd2bDfvOYTz3CP7xzql1FXGoWfOqA87vNaGBDrtOyQQnmbYeTc3Tn2OHcg==
"@budibase/backend-core@1.0.207-alpha.10":
version "1.0.207-alpha.10"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.207-alpha.10.tgz#31facb74ac2279a3ecf7d6affb933cb0ccb81860"
integrity sha512-pEyL+DY9sK6cmGv9FHLKQgrTBaTR2uMQspb/B2HGKfhiEe/wI9DgEsrvfeDt6rsD02W5xcB21FfPyyfhFvfNYw==
dependencies:
"@budibase/types" "^1.0.207-alpha.6"
"@budibase/types" "^1.0.207-alpha.10"
"@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0"
bcrypt "5.0.1"
@ -1176,12 +1176,12 @@
svelte-flatpickr "^3.2.3"
svelte-portal "^1.0.0"
"@budibase/pro@1.0.207-alpha.6":
version "1.0.207-alpha.6"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.207-alpha.6.tgz#04a81281beeb230c0c1a1f48237a94e1150a7851"
integrity sha512-IDQdKHaojfGlL8xLSQ1gYrLyipgUYPJ6Mjrrp8TcWnpwTOA2Wtzen31E5HG6YxZU8g8rN6k9S0Nsp88JKOGSrg==
"@budibase/pro@1.0.207-alpha.10":
version "1.0.207-alpha.10"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.207-alpha.10.tgz#5b1130676503eff7d84b62469e13111d3a896f09"
integrity sha512-42raVveRgHH6Qf6H1kS4lBhftTWuNJ+uhVAmDoPlHtYxuffkBVRcf6wOgYbHTN0Xx3suLrZ9yW+TupuIZQMM9Q==
dependencies:
"@budibase/backend-core" "1.0.207-alpha.6"
"@budibase/backend-core" "1.0.207-alpha.10"
node-fetch "^2.6.1"
"@budibase/standard-components@^0.9.139":
@ -1202,10 +1202,10 @@
svelte-apexcharts "^1.0.2"
svelte-flatpickr "^3.1.0"
"@budibase/types@^1.0.207-alpha.6":
version "1.0.208"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.0.208.tgz#c45cb494fb5b85229e15a34c6ac1805bae5be867"
integrity sha512-zKIHg6TGK+soVxMNZNrGypP3DCrd3jhlUQEFeQ+rZR6/tCue1G74bjzydY5FjnLEsXeLH1a0hkS5HulTmvQ2bA==
"@budibase/types@^1.0.207-alpha.10":
version "1.0.210"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.0.210.tgz#b28f9d7b37d2cbc6b75ae8de201958ccc540cf06"
integrity sha512-16foNHGAlJxvh4IpPEPw9eZyIvA2n9nssrNu54Ag73E85A+mIiZ6NGHrw+mojrdC1yaSrj/xeQ461iYXdxT6/g==
"@bull-board/api@3.7.0":
version "3.7.0"

View File

@ -291,11 +291,12 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@1.0.207-alpha.3":
version "1.0.207-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.207-alpha.3.tgz#98bced0575ec4e2b158239a8c73b39ca2d816719"
integrity sha512-DU4X6jJ+DfhzOv4TTa1w4Dk5ZEdlK/z1joCTruT+SGM5qI75bXrGeol5OX2OaEbNKtXFKJ1zeVTmBCYcu7OFUg==
"@budibase/backend-core@1.0.207-alpha.10":
version "1.0.207-alpha.10"
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.207-alpha.10.tgz#31facb74ac2279a3ecf7d6affb933cb0ccb81860"
integrity sha512-pEyL+DY9sK6cmGv9FHLKQgrTBaTR2uMQspb/B2HGKfhiEe/wI9DgEsrvfeDt6rsD02W5xcB21FfPyyfhFvfNYw==
dependencies:
"@budibase/types" "^1.0.207-alpha.10"
"@techpass/passport-openidconnect" "0.3.2"
aws-sdk "2.1030.0"
bcrypt "5.0.1"
@ -322,14 +323,19 @@
uuid "8.3.2"
zlib "1.0.5"
"@budibase/pro@1.0.207-alpha.3":
version "1.0.207-alpha.3"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.207-alpha.3.tgz#9bde845ceb685f1b43286a124620c21fdf891a01"
integrity sha512-WFEMujpKTVAMvAgLBnMdw8ou9PxsbM4Oa9Dq+DAUsWpPACsMWOProyHLsdRxJyvHlgGfwVjo5MEusvStjI4j6g==
"@budibase/pro@1.0.207-alpha.10":
version "1.0.207-alpha.10"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.207-alpha.10.tgz#5b1130676503eff7d84b62469e13111d3a896f09"
integrity sha512-42raVveRgHH6Qf6H1kS4lBhftTWuNJ+uhVAmDoPlHtYxuffkBVRcf6wOgYbHTN0Xx3suLrZ9yW+TupuIZQMM9Q==
dependencies:
"@budibase/backend-core" "1.0.207-alpha.3"
"@budibase/backend-core" "1.0.207-alpha.10"
node-fetch "^2.6.1"
"@budibase/types@^1.0.207-alpha.10":
version "1.0.210"
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.0.210.tgz#b28f9d7b37d2cbc6b75ae8de201958ccc540cf06"
integrity sha512-16foNHGAlJxvh4IpPEPw9eZyIvA2n9nssrNu54Ag73E85A+mIiZ6NGHrw+mojrdC1yaSrj/xeQ461iYXdxT6/g==
"@cspotcode/source-map-consumer@0.8.0":
version "0.8.0"
resolved "https://registry.yarnpkg.com/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz#33bf4b7b39c178821606f669bbc447a6a629786b"