A stand-alone Swift wrapper around the mongo-c client library, enabling access to MongoDB servers.

Overview

Perfect - MongoDB Connector 简体中文

Get Involed with Perfect!

Star Perfect On Github Stack Overflow Follow Perfect on Twitter Join the Perfect Slack

Swift 4.0 Platforms OS X | Linux License Apache PerfectlySoft Twitter Slack Status

NOTE: This package is deprecated in favour of the official Mongo Swift Driver. We advise users to switch to that package if possible.

--

This project provides a Swift wrapper around the mongo-c client library, enabling access to MongoDB servers.

This package builds with Swift Package Manager and is part of the Perfect project. It was written to be stand-alone and so does not require PerfectLib or any other components.

Ensure you have installed and activated the latest Swift 4.0 tool chain.

macOS Build Notes

This package requires the Homebrew build of mongo-c.

To install Homebrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

To install mongo-c:

brew install mongo-c-driver

Linux Build Notes

Ensure that you have installed components below:

apt-get install libmongoc-dev libbson-dev libssl-dev

Building

Add this project as a dependency in your Package.swift file.

.package(url: "https://github.com/PerfectlySoft/Perfect-MongoDB.git", from: "3.0.0")

Documentation

Further information can be found at perfect.org.

Comments
  • Code won't compile

    Code won't compile

    Hello, I just updated to Swift5 and I am not able to compile my project anymore. Indeed, I have a lot of type errors especially due to pointers. For example:

    error: cannot convert value of type 'UnsafeMutablePointer<bson_t>' (aka 'UnsafeMutablePointer<_bson_t>') to expected argument type 'OpaquePointer?'
    

    or

    error: '&' used with non-inout argument of type 'OpaquePointer?'
    

    Do you have any suggestion? Thank you!

    opened by xavierpantet 3
  • Fix insert(documents:) error detection

    Fix insert(documents:) error detection

    mongoc_bulk_operation_execute only indicates an error when returning 0. Any non zero value indicates success.

    See: http://mongoc.org/libmongoc/current/mongoc_bulk_operation_execute.html

    opened by sportlabsMike 1
  • Shouldn't MongoQueryFlag's static properties be public?

    Shouldn't MongoQueryFlag's static properties be public?

    public struct MongoQueryFlag: OptionSetType {
        ...
        static let None             = MongoQueryFlag(MONGOC_QUERY_NONE)
        static let TailableCursor   = MongoQueryFlag(MONGOC_QUERY_TAILABLE_CURSOR)
        static let SlaveOk          = MongoQueryFlag(MONGOC_QUERY_SLAVE_OK)
        static let OpLogReplay      = MongoQueryFlag(MONGOC_QUERY_OPLOG_REPLAY)
        static let NoCursorTimeout  = MongoQueryFlag(MONGOC_QUERY_NO_CURSOR_TIMEOUT)
        static let AwaitData        = MongoQueryFlag(MONGOC_QUERY_AWAIT_DATA)
        static let Exhaust          = MongoQueryFlag(MONGOC_QUERY_EXHAUST)
        static let Partial          = MongoQueryFlag(MONGOC_QUERY_PARTIAL)
    }
    
    opened by keyOfVv 1
  • What should I do after `make`?

    What should I do after `make`?

    I picked MongoDB for my swift-backend, everything works fine on Mac. But I have issue installing Perfect-MongoDB on my Ubuntu host. I have got *.o, *.so and *.swiftmodule files after make, what should I do thereafter?

    opened by keyOfVv 1
  • How to use find() method for select all document?

    How to use find() method for select all document?

    As the document http://www.tutorialspoint.com/mongodb/mongodb_query_document.htm. I see find() method for select all document. How use 'find()' method with this connector?

    opened by congpc 1
  • Add newObjectId() func to BSON.OID

    Add newObjectId() func to BSON.OID

    MongoDB uses special format for ObjectId. Here I've added a few functions to generate ObjectId. I will use them in my next fork of MongoDBStORM to save _id as ObjectId

    opened by TheSantaClaus 0
  • Add MongoDB-specific JSONConvertible conformance of Date

    Add MongoDB-specific JSONConvertible conformance of Date

    This adds an extension of Date that conforms to JSONConvertable in a way that MongoDB is able to natively read and understand. Prior to this, passing a Date object through MongoDB-StORM (for example) would result in a String representation being stored. This change allows MongoDB to store a native Date object which can then be queried and manipulated properly.

    opened by thislooksfun 0
  • Add init(map: [String:Any]) and append(_: date:)

    Add init(map: [String:Any]) and append(_: date:)

    This adds the convenience initializer init(map: [String: Any]) to help with conversions from dictionaries. It also adds append(key: String, date: Date) for easier usage of the native Swift Date class.

    opened by thislooksfun 0
  • adding GridFS support

    adding GridFS support

    New features: with gridfs: list(), search(), upload(), download(), info(), delete(), partiallyRead(), partiallyWrite() and corresponding Testing script

    opened by RockfordWei 0
  • Adding GridFS to MongoDB

    Adding GridFS to MongoDB

    New features: with gridfs: list(), search(), upload(), download(), info(), delete(), partiallyRead(), partiallyWrite() and corresponding Testing script

    opened by RockfordWei 0
  • getCollection does not return nil on non existing collection

    getCollection does not return nil on non existing collection

    Hi, I am not sure whether this is an intended behaviour or not but I think the way getCollection() on MongoDatabase works is a bit strange.

    The method's signature is the following:

    func getCollection(name collectionName: String) -> MongoCollection?
    

    Therefore, I expect to get a valid collection when collectionName corresponds to an existing collection in my database and nil when collectionName does not exist.

    Instead of this, I indeed get the correct collection when collectionName is valid but when it's not I'm getting new empty collection that apparently does not even belong to my database.

    Am I missing something from the doc or is there really a problem here? Thank you in advance 😄

    opened by xavierpantet 0
  • Add dependencies

    Add dependencies

    Hi, i am trying to add MongoDB Dependencies in project , I am not sure where i am making mistake.,

    i am using this ` import PackageDescription

    let package = Package( name: "SwiftBackend", products: [ .library(name: "PerfectMongoDB", targets: ["PerfectMongoDB"]) ],

    dependencies: [
        // Dependencies declare other packages that this package depends on.
        .package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", from: "3.0.0"),
        .package(url: "https://github.com/PerfectSideRepos/Perfect-CMongo.git", from: "0.0.0"),
        .package(url: "https://github.com/PerfectSideRepos/Perfect-CBSON.git", from: "0.0.0"),
        .package(url: "https://github.com/PerfectlySoft/PerfectLib.git", from: "3.0.0")
    ],
    targets: [
        .target(
            name: "SwiftBackend",
            dependencies: ["PerfectHTTPServer" , "PerfectLib" , "PerfectMongoDB"]),
        ]
    

    ) `

    Please if somebody know how to configure it plz let me know

    opened by Aishly 1
Owner
PerfectlySoft Inc.
Server-side Swift
PerfectlySoft Inc.
A stand-alone Swift wrapper around the libpq client library, enabling access to PostgreSQL servers.

Perfect - PostgreSQL Connector This project provides a Swift wrapper around the libpq client library, enabling access to PostgreSQL servers. This pack

PerfectlySoft Inc. 51 Nov 19, 2022
A stand-alone Swift wrapper around the FileMaker XML Web publishing interface, enabling access to FileMaker servers.

Perfect - FileMaker Server Connector This project provides access to FileMaker Server databases using the XML Web publishing interface. This package b

PerfectlySoft Inc. 33 Jul 13, 2022
A stand-alone Swift wrapper around the SQLite 3 client library.

Perfect - SQLite Connector This project provides a Swift wrapper around the SQLite 3 library. This package builds with Swift Package Manager and is pa

PerfectlySoft Inc. 47 Nov 19, 2022
A fast, pure swift MongoDB driver based on Swift NIO built for Server Side Swift

A fast, pure swift MongoDB driver based on Swift NIO built for Server Side Swift. It features a great API and a battle-tested core. Supporting both MongoDB in server and embedded environments.

null 646 Dec 10, 2022
A MongoDB interface for Swift [Not under active development]

MongoDB #This library is no longer under active development. I highly recommend using the robust, pure-swift alternative MongoKitten. A Swift MongoDB

Dan Appel 266 Jan 29, 2022
The official MongoDB driver for Swift

MongoSwift The official MongoDB driver for Swift applications on macOS and Linux. Index Documentation Bugs/Feature Requests Installation Step 1: Insta

mongodb 317 Jan 8, 2023
This Project domonstrate the latest Swift on Server to create RESTFul API's connected via Database: MongoDB NoSql

Swift is a general-purpose programming language built using a modern approach to safety & performance that make it specifically suitable for Server applications. Vapor is a web framework for Swift, allowing you to write backends, web apps APIs and HTTP servers in Swift

Furqan 3 Aug 23, 2022
GraphQLite is a toolkit to work with GraphQL servers easily. It also provides several other features to make life easier during iOS application development.

What is this? GraphQLite is a toolkit to work with GraphQL servers easily. It also provides several other features to make life easier during iOS appl

Related Code 2.8k Jan 9, 2023
A Cocoa / Objective-C wrapper around SQLite

FMDB v2.7 This is an Objective-C wrapper around SQLite. The FMDB Mailing List: https://groups.google.com/group/fmdb Read the SQLite FAQ: https://www.s

August 13.7k Dec 28, 2022
Simplified access to Apple's CloudKit

EVCloudKitDao Discuss EVCloudKitDao : What is this With Apple CloudKit, you can focus on your client-side app development and let iCloud eliminate the

Edwin Vermeer 632 Dec 29, 2022
An alternative to Core Data for people who like having direct SQL access.

FCModel 2 An alternative to Core Data for people who like having direct SQL access. By Marco Arment. See the LICENSE file for license info (it's the M

null 1.7k Dec 28, 2022
Easy direct access to your database 🎯

OHMySQL ★★ Every star is appreciated! ★★ The library supports Objective-C and Swift, iOS and macOS. You can connect to your remote MySQL database usin

Oleg 210 Dec 28, 2022
iForage helps foragers to track and manage foraging spots around them using CloudKit

iForage CloudKit Preface To expand on what I've created here: https://github.com/LynchConnor/iForage, I initially developed the app using Firebase. Th

Connor Lynch 3 Jul 14, 2022
A PostgreSQL client library for Swift. Does not require libpq.

PostgresClientKit PostgresClientKit provides a friendly Swift API for operating against a PostgreSQL database. Features Doesn't require libpq. Postgre

codewins.com 107 Dec 1, 2022
CoreData/Realm sweet wrapper written in Swift

What is SugarRecord? SugarRecord is a persistence wrapper designed to make working with persistence solutions like CoreData in a much easier way. Than

Modo 2.1k Dec 9, 2022
A Swift wrapper for system shell over posix_spawn with search path and env support.

AuxiliaryExecute A Swift wrapper for system shell over posix_spawn with search path and env support. Usage import AuxiliaryExecute AuxiliaryExecute.l

Lakr Aream 11 Sep 13, 2022
A Swift wrapper for SQLite databases

Squeal, a Swift interface to SQLite Squeal provides access to SQLite databases in Swift. Its goal is to provide a simple and straight-forward base API

Christian Niles 297 Aug 6, 2022
An Objective-C wrapper for RocksDB - A Persistent Key-Value Store for Flash and RAM Storage.

ObjectiveRocks ObjectiveRocks is an Objective-C wrapper of Facebook's RocksDB - A Persistent Key-Value Store for Flash and RAM Storage. Current RocksD

Iskandar Abudiab 56 Nov 5, 2022
A lightweight wrapper over UserDefaults/NSUserDefaults with an additional layer of AES-256 encryption

SecureDefaults for iOS, macOS Requirements • Usage • Installation • Contributing • Acknowledgments • Contributing • Author • License SecureDefaults is

Victor Peschenkov 216 Dec 22, 2022