Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
node-version: [18.x, 20.x, 22.x, 24.x]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ut.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
node-version: [18.x, 20.x, 22.x, 24.x]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "functional-models",
"version": "3.2.1",
"version": "3.3.0",
"description": "Functional models is ooey gooey framework for building and using awesome models EVERYWHERE.",
"main": "index.js",
"types": "index.d.ts",
Expand Down
3 changes: 3 additions & 0 deletions src/orm/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ const property = (
caseSensitive,
startsWith,
endsWith,
includes,
type,
} = options
const typeToUse = type || DatastoreValueType.string
Expand All @@ -167,6 +168,7 @@ const property = (
}
if (
equalitySymbol !== EqualitySymbol.eq &&
equalitySymbol !== EqualitySymbol.ne &&
typeToUse === DatastoreValueType.string
) {
throw new Error(`Cannot use a non = symbol for a string type`)
Expand All @@ -182,6 +184,7 @@ const property = (
..._objectize('caseSensitive', caseSensitive),
..._objectize('startsWith', startsWith),
..._objectize('endsWith', endsWith),
..._objectize('includes', includes),
},
}
return propertyEntry
Expand Down
37 changes: 22 additions & 15 deletions src/orm/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ enum EqualitySymbol {
gt = '>',
// Equal to or greater than
gte = '>=',
// Not equal to
ne = '!=',
}

/**
Expand Down Expand Up @@ -479,22 +481,18 @@ type PropertyQuery = Readonly<{
/**
* Options for additional matching.
*/
options: {
/**
* Should this be a case sensitive search. (for text)
*/
caseSensitive?: boolean
/**
* Indicates that the value is a "startsWith" query.
*/
startsWith?: boolean
/**
* Indicates that the value is a "endsWith" query.
*/
endsWith?: boolean
}
options: PropertyOptions
}>

/**
* A property search for a string value.
*/
type StringPropertyQuery = PropertyQuery & {
valueType: DatastoreValueType.string
equalitySymbol: EqualitySymbol.eq | EqualitySymbol.ne
options: PropertyOptions
}

/**
* A search that looks at dated objects after the given date.
* @interface
Expand Down Expand Up @@ -601,6 +599,10 @@ type PropertyOptions = {
* Is the value a endsWith query?
*/
endsWith?: boolean
/**
* Is the value a includes query?
*/
includes?: boolean
/**
* The type of value
*/
Expand Down Expand Up @@ -686,7 +688,11 @@ type OrmSearch = {
/**
* Statements that make up the meat of QueryTokens
*/
type Query = PropertyQuery | DatesAfterQuery | DatesBeforeQuery
type Query =
| PropertyQuery
| DatesAfterQuery
| DatesBeforeQuery
| StringPropertyQuery

/**
* A token type that links two queries together.
Expand Down Expand Up @@ -841,4 +847,5 @@ export {
QueryTokens,
InnerBuilderV2,
SortOrder,
StringPropertyQuery,
}
7 changes: 7 additions & 0 deletions test/src/orm/query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,13 @@ describe('/src/orm/query.ts', () => {
})
}, 'blah is not a valid symbol')
})
it('should NOT throw an exception if the type is string and equalitySymbol is ne', () => {
assert.doesNotThrow(() => {
property('my-name', 'my-value', {
equalitySymbol: EqualitySymbol.ne,
})
})
})
})
describe('#and()', () => {
it('should return AND', () => {
Expand Down