diff --git a/.github/workflows/feature.yml b/.github/workflows/feature.yml index a8f1d4d..7907e1a 100644 --- a/.github/workflows/feature.yml +++ b/.github/workflows/feature.yml @@ -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 diff --git a/.github/workflows/ut.yml b/.github/workflows/ut.yml index 2817c07..12aaf07 100644 --- a/.github/workflows/ut.yml +++ b/.github/workflows/ut.yml @@ -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 diff --git a/package.json b/package.json index 5f808c8..3dba2d7 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/orm/query.ts b/src/orm/query.ts index a081a99..49fcf8a 100644 --- a/src/orm/query.ts +++ b/src/orm/query.ts @@ -159,6 +159,7 @@ const property = ( caseSensitive, startsWith, endsWith, + includes, type, } = options const typeToUse = type || DatastoreValueType.string @@ -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`) @@ -182,6 +184,7 @@ const property = ( ..._objectize('caseSensitive', caseSensitive), ..._objectize('startsWith', startsWith), ..._objectize('endsWith', endsWith), + ..._objectize('includes', includes), }, } return propertyEntry diff --git a/src/orm/types.ts b/src/orm/types.ts index a1cd033..768e27c 100644 --- a/src/orm/types.ts +++ b/src/orm/types.ts @@ -28,6 +28,8 @@ enum EqualitySymbol { gt = '>', // Equal to or greater than gte = '>=', + // Not equal to + ne = '!=', } /** @@ -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 @@ -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 */ @@ -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. @@ -841,4 +847,5 @@ export { QueryTokens, InnerBuilderV2, SortOrder, + StringPropertyQuery, } diff --git a/test/src/orm/query.test.ts b/test/src/orm/query.test.ts index 85acaf9..14fe111 100644 --- a/test/src/orm/query.test.ts +++ b/test/src/orm/query.test.ts @@ -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', () => {