Skip to content

Commit

Permalink
Merge pull request #10 from monolithst/fix-fetch
Browse files Browse the repository at this point in the history
fix(fetch): fix fetcher
  • Loading branch information
macornwell committed Apr 17, 2024
2 parents f48af50 + aaf66da commit 80b57da
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "functional-models-orm",
"version": "2.1.3",
"version": "2.1.4",
"description": "A basic ORM building library using the functional-models library.",
"main": "index.js",
"types": "index.d.ts",
Expand Down Expand Up @@ -84,10 +84,11 @@
"mocha": "^10.4.0",
"nodemon": "^3.1.0",
"nyc": "^15.1.0",
"prettier": "^3.2.5",
"proxyquire": "^2.1.3",
"sinon": "^11.1.2",
"source-map-support": "^0.5.21",
"ts-node": "^10.4.0",
"ts-node": "^10.9.2",
"typescript": "^4.9.5"
},
"homepage": "https://github.com/monolithst/functional-models-orm#readme",
Expand Down
6 changes: 1 addition & 5 deletions src/orm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ const orm = ({
model: Model<T>,
id: PrimaryKeyType
) => {
const obj = await retrieve<T, TModel>(model as TModel, id)
if (obj) {
return obj.toObj()
}
return undefined
return retrieve<T, TModel>(model as TModel, id)
}

const retrieve = async <
Expand Down
7 changes: 4 additions & 3 deletions test/src/orm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,11 @@ describe('/src/orm.ts', () => {
)

// @ts-ignore
const actual = await await instance.fetcher<{ name: string }>(
model,
'my-id'
const actual = await (
await instance.fetcher<{ name: string }>(model, 'my-id')
)
// @ts-ignore
.toObj()
const expected = { id: 'my-id', name: 'my-name' }
assert.deepEqual(actual, expected)
})
Expand Down

0 comments on commit 80b57da

Please sign in to comment.