Skip to content

Commit 859f830

Browse files
authored
Merge pull request #28 from jhomarolo/master
feat(first): add first method feature
2 parents c2ed159 + e6db241 commit 859f830

File tree

11 files changed

+2569
-1973
lines changed

11 files changed

+2569
-1973
lines changed

.eslintrc.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
"Atomics": "readonly",
1111
"SharedArrayBuffer": "readonly"
1212
},
13-
"parser": "babel-eslint",
13+
"parser": "@babel/eslint-parser",
1414
"parserOptions": {
15-
"ecmaVersion": 2018
15+
"ecmaVersion": 2018,
16+
"requireConfigFile":false
1617
},
1718
"rules": {
1819
"semi": ["error", "never"],

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v2
1616

17-
- name: Use Node.js (12.16.2)
17+
- name: Use Node.js (14.15.0)
1818
uses: actions/setup-node@v1
1919
with:
20-
node-version: '12.16.2'
20+
node-version: '14.15.0'
2121

2222
- name: Install Packages
2323
run: npm ci

.github/workflows/on_pull_request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010

1111
strategy:
1212
matrix:
13-
node-version: [12.x]
13+
node-version: [14.x]
1414

1515
steps:
1616
- uses: actions/checkout@v2

.github/workflows/on_push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010

1111
strategy:
1212
matrix:
13-
node-version: [12.x]
13+
node-version: [14.x]
1414

1515
steps:
1616
- uses: actions/checkout@v2

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ class YourRepository extends Repository {
139139
## Retrieving and Persisting Data
140140

141141
### `find`
142-
Find entities
142+
Find entities matched by the filter, or empty array `[]` if there is no matching entity.
143143

144-
Format: `.find(options)` where `options` is a optional object containing `{ limit, offset, orderBy, conditions }`
144+
Format: `.find(options)` where `options` is a optional object containing `{ limit, offset, orderBy, where }`
145145

146146
Return: Entity array
147147

@@ -181,12 +181,12 @@ const repo = new ItemRepository(injection)
181181
const ret = await repo.find({ orderBy: [{ column: 'nome', order: 'desc' }, 'email'] })
182182
```
183183

184-
- `conditions`
184+
- `where`
185185
Adds a filter to the query with given values.
186186

187187
```javascript
188188
const repo = new ItemRepository(injection)
189-
const ret = await repo.find({ conditions: { name: ["Anne"] } })
189+
const ret = await repo.find({ where: { name: ["Anne"] } })
190190
```
191191

192192
### `findByID`
@@ -201,6 +201,18 @@ const repo = new ItemRepository(injection)
201201
const ret = await repo.findByID(10)
202202
```
203203

204+
### `first`
205+
Finds the first entity matched by the filter, or empty array `[]` if there is no matching entity.
206+
207+
Format: `.first(options)` where `options` is a optional object containing `{ orderBy, where }`
208+
209+
Return: Entity
210+
211+
```javascript
212+
const repo = new ItemRepository(injection)
213+
const ret = await repo.first({ orderBy: 'description'})
214+
```
215+
204216
### `insert`
205217

206218
Insert an Entity into a table.

0 commit comments

Comments
 (0)