Skip to content

doubleloop-io/effect-mongodb

Folders and files

NameName
Last commit message
Last commit date
Feb 28, 2025
Dec 6, 2024
Mar 21, 2025
Oct 11, 2024
Jan 3, 2025
Oct 18, 2024
Oct 18, 2024
Jul 5, 2024
Oct 18, 2024
Jan 17, 2025
Jul 5, 2024
Feb 28, 2025
Jan 2, 2025
Jan 17, 2025
Nov 13, 2024
Feb 7, 2025
Feb 7, 2025
Oct 11, 2024
Jan 3, 2025
Nov 15, 2024
Nov 15, 2024
Nov 15, 2024
Oct 18, 2024

Repository files navigation

effect-mongodb

CI status effect-mongodb npm version

A MongoDB toolkit for Effect.

import { Effect, Schema } from "effect"
import { Collection, Db, FindCursor, MongoClient } from "effect-mongodb"

const Person = Schema.Struct({
  name: Schema.String,
  age: Schema.Number,
  birthday: Schema.Date
})

const program = Effect.gen(function*() {
  const client = yield* MongoClient.connectScoped("mongodb://localhost:27017")
  const db = MongoClient.db(client, "source-db")
  const sourceCollection = Db.collection(db, "source", Person)
  const destinationCollection = Db.collection(db, "destination", Person)

  const items = yield* Collection.find(sourceCollection).pipe(FindCursor.toArray)

  yield* Collection.insertMany(destinationCollection, items)
})

await program.pipe(Effect.scoped, Effect.runPromise)

Documentation

effect-mongodb is the core package that provides effectful APIs to work with MongoDB.

@effect-mongodb/services is the package that provides Effect services for effect-mongodb.

MongoDB driver compatibility

We adhere to the MongoDB driver compatibility guidelines, so minor releases might break compatibility with older MongoDB servers.

For example, upgrading the Node.js driver from 6.8 to 6.10 will make it incompatible with MongoDB server 3.6.

Contributing

Take a look at the CONTRIBUTING.md guidelines.

Found a Bug?

If you find a bug in the source code, you can help us by submitting an issue to our GitHub Repository. Even better, you can submit a Pull Request with a fix.

Missing a Feature?

You can request a new feature by submitting a discussion to our GitHub Repository. If you would like to implement a new feature, please consider the size of the change and reach out to better coordinate our efforts and prevent duplication of work.

License

effect-mongodb is made available under the terms of the MIT License.

See the LICENSE file for license details.

About

A MongoDB toolkit for Effect

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3