Welcome, we really appreciate if you're considering to contribute to effect-mongodb!
Install the following tools to set up your environment:
Then, you can fork the repository and install the dependencies:
- Fork this repository on GitHub
- Clone your forked repo:
git clone https://github.com/<username>/effect-mongodb && cd effect-mongodb
- Install dependencies:
pnpm install
- Optionally, verify that everything is working correctly:
pnpm check pnpm test
Create a new branch for your changes
git checkout -b my-branchMake the changes you propose to the codebase. If your changes impact functionality, please add corresponding tests to validate your updates.
Run the following commands to ensure your changes do not introduce any issues:
pnpm codegen(optional): Re-generate the package entrypoints in case you have changed the structure of a package or introduced a new module.pnpm check: Confirm that the code compiles without errors.pnpm test: Execute all unit tests to ensure your changes haven't broken existing functionality.pnpm circular: Check for any circular dependencies in imports.pnpm lint: Ensure the code adheres to our coding standards.- If you encounter style issues, use
pnpm lint-fixto automatically correct some of these.
- If you encounter style issues, use
pnpm dtslint: Run type-level tests.
Before committing your changes, document them with a changeset. This process helps in tracking modifications and effectively communicating them to the project team and users:
pnpm changesetDuring the changeset creation process, you will be prompted to select the appropriate level for your changes:
- patch: Opt for this if you are making small fixes or minor changes that do not affect the library's overall functionality.
- minor: Choose this for new features that enhance functionality but do not disrupt existing features.
- major: Select this for any changes that result in backward-incompatible modifications to the library.
Once you have documented your changes, commit them to the repository:
git commit -am "Add some feature"If your commit addresses an open issue, reference the issue number directly in your commit message. This helps to link your contribution clearly to specific tasks or bug reports.
For example:
# Reference issue #123
git commit -am "Add some feature (#123)"
# Close the issue #123
git commit -am "Add some feature (close #123)"Push the changes to your GitHub fork:
git push origin my-branchOpen a pull request against the main branch on the original repository.
Please be patient! We will do our best to review your pull request as soon as possible.
We use @testcontainers/mongodb to run MongoDB in a Docker container during tests.
In the test directory of a package, like packages/effect-mongodb/test, create a
new file <test suite name>.test.ts.
Use the describeMongo function to automatically setup your test suite with a MongoDB connection.
import * as Db from "effect-mongodb/Db"
import * as DocumentCollection from "effect-mongodb/DocumentCollection"
import * as Effect from "effect/Effect"
import * as O from "effect/Option"
import { ObjectId } from "mongodb"
import { expect, test } from "vitest"
import { describeMongo } from "./support/describe-mongo.js"
describeMongo("My tests", (ctx) => {
test("find one", async () => {
const program = Effect.gen(function*() {
const db = yield* ctx.database
const collection = Db.documentCollection(db, "find-one")
yield* DocumentCollection.insertMany(collection, [{ name: "john" }, { name: "alfred" }])
return yield* DocumentCollection.findOne(collection, { name: "john" })
})
const result = await Effect.runPromise(program)
expect(result).toEqual(O.some({ _id: expect.any(ObjectId), name: "john" }))
})
})- Export
EFFECT_MONGODB_DEBUG=trueenvironment variable - Run the tests (by default in watch mode) and you will see the connection string in the console output
[EFFECT_MONGODB_DEBUG] MongoDB connection string with direct connection: 'mongodb://localhost:32775' - Copy the connection string
mongodb://localhost:32775 - Open MongoDB Compass
- Click Add new connection
- Paste the copied connection string in the URI field
- Click Advanced Connection Options
- Enable Direct Connection
- Click Save & Connect