From c5060b3533eaf1e12cb61d8f5d7f8c478f4fcf95 Mon Sep 17 00:00:00 2001 From: Mike Cornwell Date: Mon, 12 Jan 2026 10:23:10 -0500 Subject: [PATCH 1/7] feat(name): add ability to adjust name. Useful for loading and unloading data --- package.json | 2 +- src/datastoreAdapter.ts | 12 ++++++------ src/lib.ts | 5 +++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 5eb9f48..3ff8e5c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "functional-models-orm-memory", - "version": "3.0.0", + "version": "3.0.1", "description": "An in-memory datastore adapter for functional-models", "main": "index.js", "types": "index.d.ts", diff --git a/src/datastoreAdapter.ts b/src/datastoreAdapter.ts index 0076217..889f280 100644 --- a/src/datastoreAdapter.ts +++ b/src/datastoreAdapter.ts @@ -12,7 +12,7 @@ import { } from 'functional-models' import clone from 'lodash/clone' import merge from 'lodash/merge' -import { filterResults } from './lib' +import { defaultCollectionName, filterResults } from './lib' type WithRequired = T & { [P in K]-?: T[P] } @@ -20,10 +20,10 @@ type Props = { seedData?: Record> } -const create = ({ seedData }: Props = {}): WithRequired< - DatastoreAdapter, - 'count' -> => { +const create = ({ + seedData, + getCollectionNameForModel = defaultCollectionName, +}: Props = {}): WithRequired => { const database: Record> = clone( seedData ) || {} @@ -31,7 +31,7 @@ const create = ({ seedData }: Props = {}): WithRequired< const _getRecords = ( model: ModelType ) => { - const name = model.getName() + const name = getCollectionNameForModel(model) if (!(name in database)) { // eslint-disable-next-line functional/immutable-data database[name] = {} diff --git a/src/lib.ts b/src/lib.ts index 00bd699..75c6091 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -8,6 +8,7 @@ import { EqualitySymbol, isALinkToken, isPropertyBasedQuery, + ModelType, OrmSearch, PropertyQuery, Query, @@ -189,4 +190,8 @@ const filterResults = ( return databaseEntries.filter(func) } +export const defaultCollectionName = (model: ModelType) => { + return model.getName() +} + export { filterResults } From b0465e8e50c2df282a8d609f200f621fb7b16564 Mon Sep 17 00:00:00 2001 From: Mike Cornwell Date: Mon, 12 Jan 2026 10:25:08 -0500 Subject: [PATCH 2/7] fix(fix): minor fixes --- src/datastoreAdapter.ts | 3 +++ src/lib.ts | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/datastoreAdapter.ts b/src/datastoreAdapter.ts index 889f280..b894c40 100644 --- a/src/datastoreAdapter.ts +++ b/src/datastoreAdapter.ts @@ -18,6 +18,9 @@ type WithRequired = T & { [P in K]-?: T[P] } type Props = { seedData?: Record> + getCollectionNameForModel?: ( + model: ModelType + ) => string } const create = ({ diff --git a/src/lib.ts b/src/lib.ts index 75c6091..d5cd9a7 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -190,7 +190,9 @@ const filterResults = ( return databaseEntries.filter(func) } -export const defaultCollectionName = (model: ModelType) => { +export const defaultCollectionName = ( + model: ModelType +) => { return model.getName() } From c82775dfbc8a5c84c64845bb6c0143e10e8d5ec6 Mon Sep 17 00:00:00 2001 From: Mike Cornwell Date: Mon, 12 Jan 2026 10:28:47 -0500 Subject: [PATCH 3/7] fix(ne): add support for NE --- package.json | 2 +- src/lib.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 3ff8e5c..876d53e 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ }, "dependencies": { "date-fns": "^3.6.0", - "functional-models": "^3.0.12", + "functional-models": "^3.6.4", "lodash": "^4.17.21" } } diff --git a/src/lib.ts b/src/lib.ts index d5cd9a7..53b8a82 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -63,6 +63,8 @@ const _checks = { searchValue > dataValue, [EqualitySymbol.lte]: (searchValue: number, dataValue: number) => searchValue >= dataValue, + [EqualitySymbol.ne]: (searchValue: number, dataValue: number) => + searchValue !== dataValue, } const _numberCompare = _emptyValueWrapper((property: PropertyQuery) => { From 2d2471fee4b06de2400359b64214a270beb52b55 Mon Sep 17 00:00:00 2001 From: Mike Cornwell Date: Mon, 12 Jan 2026 10:29:11 -0500 Subject: [PATCH 4/7] chore(version): bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 876d53e..177560a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "functional-models-orm-memory", - "version": "3.0.1", + "version": "3.0.2", "description": "An in-memory datastore adapter for functional-models", "main": "index.js", "types": "index.d.ts", From 638096e06a8ae324bb6667f449006041c4ecedb7 Mon Sep 17 00:00:00 2001 From: Mike Cornwell Date: Mon, 12 Jan 2026 10:33:05 -0500 Subject: [PATCH 5/7] test(tests): fix tests --- test/src/datastoreAdapter.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/src/datastoreAdapter.test.ts b/test/src/datastoreAdapter.test.ts index 15ec9f5..482a080 100644 --- a/test/src/datastoreAdapter.test.ts +++ b/test/src/datastoreAdapter.test.ts @@ -8,7 +8,7 @@ import { import { create } from '../../src/datastoreAdapter' const getSeedData1 = () => ({ - 'functional-models-orm-memory-test-1-models': { + 'functional-models-orm-memory/Test1Models': { '29a766b5-e77b-4099-a7f2-61cda0a29cc3': { id: '29a766b5-e77b-4099-a7f2-61cda0a29cc3', name: 'my-name-1', From 2f1f064c74e0bc6b725cbf50b5a50e53e9a9b480 Mon Sep 17 00:00:00 2001 From: Mike Cornwell Date: Mon, 12 Jan 2026 10:34:59 -0500 Subject: [PATCH 6/7] test(features): fix feature tests --- features/step_definitions/steps.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/step_definitions/steps.ts b/features/step_definitions/steps.ts index 2d43b98..c2bdf42 100644 --- a/features/step_definitions/steps.ts +++ b/features/step_definitions/steps.ts @@ -6,7 +6,7 @@ import { createOrm, Orm, PrimaryKeyUuidProperty, queryBuilder, TextProperty } fr const SeedData = { SeedData1: () => { return { - 'functional-models-orm-memory-test-1-models': { + 'functional-models-orm-memory/Test1Models': { '29a766b5-e77b-4099-a7f2-61cda0a29cc3': { id: '29a766b5-e77b-4099-a7f2-61cda0a29cc3', name: 'my-name-1', From 8555a6c3dcc4465f318d7eb9b330dca8ce08cb28 Mon Sep 17 00:00:00 2001 From: Mike Cornwell Date: Mon, 12 Jan 2026 10:41:07 -0500 Subject: [PATCH 7/7] test(tests): add tests --- src/lib.ts | 4 ++++ test/src/lib.test.ts | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/lib.ts b/src/lib.ts index 53b8a82..6c43f41 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -24,6 +24,10 @@ const _emptyValueWrapper = const isEmptyCheck = property.value === undefined || property.value === null const subfunc = func(property) return (obj: object) => { + // If we are searching for a value that is not equal to the given value, return true if the value is not equal to the given value + if (property.equalitySymbol === EqualitySymbol.ne) { + return subfunc(obj) + } // @ts-ignore const value = obj[property.key] const valueIsEmpty = value === undefined || value === null diff --git a/test/src/lib.test.ts b/test/src/lib.test.ts index 3d0c438..5f581ec 100644 --- a/test/src/lib.test.ts +++ b/test/src/lib.test.ts @@ -254,6 +254,19 @@ describe('/src/lib.ts', () => { const expected = 2 assert.deepEqual(actual, expected) }) + it('should return 4 results with TestData1 when searching != 7', () => { + const actual = filterResults( + queryBuilder() + .property('aNumber', 7, { + type: DatastoreValueType.number, + equalitySymbol: EqualitySymbol.ne, + }) + .compile(), + TestData1 + ) + const expected = 4 + assert.deepEqual(actual.length, expected) + }) it('should return 4 results with TestData1 when searching > 1', () => { const actual = filterResults( queryBuilder()