Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vapor-community/mongo-driver
MongoDB driver for Fluent
https://github.com/vapor-community/mongo-driver
fluent fluent-driver vapor
Last synced: 3 months ago
JSON representation
MongoDB driver for Fluent
- Host: GitHub
- URL: https://github.com/vapor-community/mongo-driver
- Owner: vapor-community
- Created: 2016-05-18T18:51:06.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-26T13:18:40.000Z (about 6 years ago)
- Last Synced: 2024-05-18T22:53:17.383Z (6 months ago)
- Topics: fluent, fluent-driver, vapor
- Language: Swift
- Size: 120 KB
- Stars: 28
- Watchers: 18
- Forks: 26
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- TheList - MongoDB driver for Fluent - MongoDB driver for Fluent. (Database Connectors / MongoDB)
README
# Mongo Driver for Fluent
![Swift](http://img.shields.io/badge/swift-3.1-brightgreen.svg)
[![Slack Status](http://vapor.team/badge.svg)](http://vapor.team)## Install the MongoDB server
For more instructions, check out https://docs.mongodb.com/master/administration/install-community/.
### OS X
```shell
brew install mongodb
```### Ubuntu
```shell
sudo apt-get update
sudo apt-get install mongodb
```## Run the MongoDB server
```shell
mongod
```## Connecting to MongoDB with Fluent
You need to edit `Config/fluent.json` to define mongo as the underlying database technology to use as driver for Fluent:
```json
{
"driver": "mongo"
}
```Creating a driver is done using the [MongoDB Connection String URI Format](https://docs.mongodb.com/manual/reference/connection-string/). Initializing a `MongoDriver` such a URI will attempt a connection to MongoDB.
```swift
import MongoDriver
import Fluentlet driver = try MongoDriver("mongodb://localhost")
let db = Fluent.Database(driver)
```