Skip to content

Commit

Permalink
feat: modernize
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Oct 12, 2024
1 parent fd2b98f commit cc6affc
Show file tree
Hide file tree
Showing 10 changed files with 1,240 additions and 1,625 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: yarn --frozen-lockfile

- name: build
run: yarn build-prod
run: yarn build

- name: release
env:
Expand Down
5 changes: 1 addition & 4 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/bin/sh
[ -n "$CI" ] && exit 0
. "$(dirname "$0")/_/husky.sh"

yarn commitlint-def $1
# exit 1 # uncomment to debug
dev-lib commitlint $1
4 changes: 1 addition & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/sh
[ -n "$CI" ] && exit 0
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged-def
dev-lib lint-staged
4 changes: 4 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
"extends": ["node_modules/@naturalcycles/dev-lib/cfg/biome.jsonc"]
}
4 changes: 4 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// prettier-ignore
module.exports = [
...require('@naturalcycles/dev-lib/cfg/eslint.config'),
]
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"name": "@naturalcycles/mongo-lib",
"scripts": {
"prepare": "husky"
"prepare": "husky",
"build": "dev-lib build",
"test": "dev-lib test",
"lint": "dev-lib lint",
"bt": "dev-lib bt",
"lbt": "dev-lib lbt"
},
"dependencies": {
"@naturalcycles/db-lib": "^9.0.0",
Expand All @@ -10,8 +15,8 @@
"mongodb": "^6.0.0"
},
"devDependencies": {
"@naturalcycles/dev-lib": "^13.6.0",
"@types/node": "^20.5.9",
"@naturalcycles/dev-lib": "^15.22.0",
"@types/node": "^22.7.5",
"dotenv": "^16.0.0",
"jest": "^29.0.3"
},
Expand All @@ -33,7 +38,7 @@
"url": "https://github.com/NaturalCycles/mongo-lib"
},
"engines": {
"node": ">=18.12.0"
"node": ">=20.13.0"
},
"version": "3.4.16",
"description": "MongoDB implementation of CommonDB interface",
Expand Down
1 change: 1 addition & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@naturalcycles/dev-lib/cfg/prettier.config')
13 changes: 7 additions & 6 deletions src/mongo.db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import {
RunQueryResult,
} from '@naturalcycles/db-lib'
import {
_assert,
_filterUndefinedValues,
_Memo,
_omit,
ObjectWithId,
CommonLogger,
commonLoggerPrefix,
_assert,
ObjectWithId,
} from '@naturalcycles/js-lib'
import { ReadableTyped } from '@naturalcycles/nodejs-lib'
import { CommandOperationOptions, Filter, MongoClient, MongoClientOptions } from 'mongodb'
Expand Down Expand Up @@ -49,7 +49,8 @@ export class MongoDB extends BaseCommonDB implements CommonDB, AsyncDisposable {
updateSaveMethod: false,
tableSchemas: false,
transactions: false,
updateByQuery: false,
patchByQuery: false,
increment: false,
}

constructor(cfg: MongoDBCfg) {
Expand Down Expand Up @@ -201,7 +202,7 @@ export class MongoDB extends BaseCommonDB implements CommonDB, AsyncDisposable {
const items = (await client
.db(this.cfg.db)
.collection<ROW>(q.table)
.find(query, options) // eslint-disable-line unicorn/no-array-method-this-argument
.find(query, options)
.toArray()) as any as MongoObject<ROW>[]

let rows = items.map(i => this.mapFromMongo(i as any))
Expand All @@ -224,7 +225,7 @@ export class MongoDB extends BaseCommonDB implements CommonDB, AsyncDisposable {
const items: MongoObject<any>[] = await client
.db(this.cfg.db)
.collection<ROW>(q.table)
.find(query, options) // eslint-disable-line unicorn/no-array-method-this-argument
.find(query, options)
.toArray()
return items.length
}
Expand Down Expand Up @@ -259,7 +260,7 @@ export class MongoDB extends BaseCommonDB implements CommonDB, AsyncDisposable {
client
.db(this.cfg.db)
.collection<ROW>(q.table)
.find(query, options) // eslint-disable-line unicorn/no-array-method-this-argument
.find(query, options)
.stream()
.on('error', err => transform.emit('error', err))
.pipe(transform)
Expand Down
2 changes: 1 addition & 1 deletion src/test/mongo.manual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { CommonDao, CommonDaoLogLevel } from '@naturalcycles/db-lib'
import { runCommonDaoTest, runCommonDBTest } from '@naturalcycles/db-lib/dist/testing'
import {
createTestItemsBM,
testItemBMSchema,
TEST_TABLE,
testItemBMSchema,
} from '@naturalcycles/db-lib/dist/testing/test.model'
import { requireEnvKeys } from '@naturalcycles/nodejs-lib'
import { MongoDB } from '../mongo.db'
Expand Down
Loading

0 comments on commit cc6affc

Please sign in to comment.