1.1.3 • Published 2 months ago

@sigiljs-community/mongo-plugin v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Sigil MongoDB Plugin

Plugin for SigilJS framework that provides MongoDB interactions

Installation

npm install @sigiljs-community/mongo-plugin
# or
yarn add @sigiljs-community/mongo-plugin

Usage

Import and register the plugin

import { Sigil } from "@sigiljs/sigil"
import { MongoPlugin } from "@sigiljs-community/mongo-plugin"

const app = new Sigil()

// Register plugin with settings
app.addPlugin(MongoPlugin, {
  /**
   * Mongo connect URI, required
   */
  connectUri: "mongodb://...",

  /**
   *  MongoDB client options, you can read more about it
   * in the mongo SDK documentation
   */
  clientOptions: {}
})

Creating and interacting with controller

const controller = app.plugin(MongoPlugin).createController("databaseName")

const usersCollection = controller.collection<{ userId: string }>("users")

// usersCollection is an instance of MongoDB collection

Disconnecting and reconnecting

// Disconnect from current instance
controller.disconnect()

// Reconnect to current instance
controller.reconnect()

License

You can copy and paste the MIT license summary from below.

MIT License

Copyright (c) 2022 Kurai Foundation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
1.1.3

2 months ago

1.1.2

2 months ago

1.1.1

2 months ago

1.1.0

2 months ago

1.0.0

2 months ago