All Projects → AngelMunoz → Mondocks

AngelMunoz / Mondocks

Licence: mit
An alternative way to interact with MongoDB databases from F# that allows you to use mongo-idiomatic constructs

Programming Languages

fsharp
127 projects

Projects that are alternatives of or similar to Mondocks

Android Nosql
Lightweight, simple structured NoSQL database for Android
Stars: ✭ 284 (+1320%)
Mutual labels:  mongo, mongodb, nosql
Grandnode
Open source, headless, multi-tenant eCommerce platform built with .NET Core, MongoDB, AWS DocumentDB, Azure CosmosDB, Vue.js.
Stars: ✭ 1,768 (+8740%)
Mutual labels:  mongodb, nosql, dotnet-core
Variety
A schema analyzer for MongoDB
Stars: ✭ 1,592 (+7860%)
Mutual labels:  mongo, mongodb, nosql
Westore
更好的小程序项目架构
Stars: ✭ 3,897 (+19385%)
Mutual labels:  mongo, mongodb, nosql
Odmantic
Async ODM (Object Document Mapper) for MongoDB based on python type hints
Stars: ✭ 240 (+1100%)
Mutual labels:  mongo, mongodb, nosql
Gokv
Simple key-value store abstraction and implementations for Go (Redis, Consul, etcd, bbolt, BadgerDB, LevelDB, Memcached, DynamoDB, S3, PostgreSQL, MongoDB, CockroachDB and many more)
Stars: ✭ 314 (+1470%)
Mutual labels:  mongodb, library
Dotnetguide
🦸【C#/.NET/.NET Core学习、工作、面试指南】概述:C#/.NET/.NET Core基础知识,学习资料、文章、书籍,社区组织,工具和常见的面试题总结。以及面试时需要注意的事项和优秀简历编写技巧,希望能和大家一起成长进步👊。【让现在的自己不再迷漫✨】
Stars: ✭ 308 (+1440%)
Mutual labels:  mongodb, nosql
Mongoengine
MongoEngine is a Python Object-Document Mapper for working with MongoDB. Documentation is available at https://mongoengine-odm.readthedocs.io - there is currently a tutorial, a user guide, and an API reference.
Stars: ✭ 3,632 (+18060%)
Mutual labels:  mongo, mongodb
Mongo Seeding
The ultimate solution for populating your MongoDB database.
Stars: ✭ 375 (+1775%)
Mutual labels:  mongo, mongodb
Lungo
A MongoDB compatible embeddable database and toolkit for Go.
Stars: ✭ 343 (+1615%)
Mutual labels:  mongo, mongodb
Mongo
The MongoDB Database
Stars: ✭ 20,883 (+104315%)
Mutual labels:  mongodb, nosql
Fullstack Apollo Express Mongodb Boilerplate
💥A sophisticated GraphQL with Apollo, Express and MongoDB boilerplate project.
Stars: ✭ 301 (+1405%)
Mutual labels:  mongo, mongodb
Hexagonal Architecture Acerola
An Hexagonal Architecture service template with DDD, CQRS, TDD and SOLID using .NET Core 2.0. All small features are testable and could be mocked. Adapters could be mocked or exchanged.
Stars: ✭ 293 (+1365%)
Mutual labels:  mongodb, dotnet-core
Nosqlclient
Cross-platform and self hosted, easy to use, intuitive mongodb management tool - Formerly Mongoclient
Stars: ✭ 3,399 (+16895%)
Mutual labels:  mongodb, nosql
Gonorth
GoNorth is a story and content planning tool for RPGs and other open world games.
Stars: ✭ 289 (+1345%)
Mutual labels:  mongodb, dotnet-core
Migrate Mongo
A database migration tool for MongoDB in Node
Stars: ✭ 481 (+2305%)
Mutual labels:  mongo, mongodb
Csharp Driver
DataStax C# Driver for Apache Cassandra
Stars: ✭ 477 (+2285%)
Mutual labels:  nosql, dotnet-core
Denodb
MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno
Stars: ✭ 498 (+2390%)
Mutual labels:  mongo, mongodb
Restheart
RESTHeart - The REST API for MongoDB
Stars: ✭ 659 (+3195%)
Mutual labels:  mongodb, nosql
Entityframeworkcore
NoSQL providers for EntityFramework Core
Stars: ✭ 259 (+1195%)
Mutual labels:  mongodb, dotnet-core

Mondocks

nuget Binder

dotnet add package Mondocks

This library is based on the mongodb extended json spec and mongodb manual reference

https://docs.mongodb.com/manual/reference/mongodb-extended-json/ > https://docs.mongodb.com/manual/reference/command/

This library provides a set of familiar tools if you work with mongo databases and can be a step into more F# goodies, it doesn't prevent you from using the usual MongoDB/.NET driver so you can use them side by side. It also can help you if you have a lot of flexible data inside your database as oposed to the usual strict schemas that F#/C# are used to from SQL tools, this provides a DSL that allow you to create MongoDB Commands (raw queries) leveraging the dynamism of anonymous records since they behave almost like javascript objects. Writing commands should be almost painless these commands produce a JSON string that can be utilized directly on your application or even copy/pasted into the mongo shell. Commands are kind of a version of raw sql queries but they allow you to do what you already know how to do without much changes to the objects you might be manipulating already. Ideally this library is meant to be used mostly with records and anonymous records to imitate mongodb queries

Sample Usage

Check out this quick sample of what you can do right now

You can also check this gist

open System
open MongoDB.Driver
open MongoDB.Bson
open Mondocks.Queries
open Mondocks.Types

type User = { _id: ObjectId; name: string; age: int }
let createUsers minAge maxAge =
    let random  = Random()
    insert "users" {
        documents
            [   // an anonymous object that does not include a null _id
                {| name = "Peter"; age = random.Next(minAge, maxAge); |}
                {| name = "Sandra"; age = random.Next(minAge, maxAge); |}
                {| name = "Mike"; age = random.Next(minAge, maxAge); |}
                {| name = "Perla"; age = random.Next(minAge, maxAge); |}
                {| name = "Updateme"; age = 1; |}
                {| name = "Deleteme"; age = 50; |}
            ]
    }
let getUsersOverAge (age: int) =
    find "users" {
        // equivalent to a mongo query filter
        // { age: { $gt: age } }
        filter {| age = {| ``$gt``= age |} |}
        limit 2
        skip 1
    }
let updateUser (name: string) (newName: string) =
    update "users" {
        updates
            [ { // you can do mongo queries like
                // {| ``$or`` = [] |} -> { $or: [] }
                q = {| name = name |}
                u = {| name = newName; age = 5 |}
                multi = Some false
                upsert = Some false
                collation = None
                arrayFilters = None
                hint = None }
            ]
    }
let deleteUser (name: string) =
    delete "users" {
        deletes
           [ { q = {| name = name |}
               limit = 1
               collation = None
               hint = None
               comment = None }
        ]
    }
[<EntryPoint>]
let main argv =
    let client = MongoClient("mongodb://localhost:27017")
    let db = client.GetDatabase("mondocks")

    let userscmd = createUsers 15 50
    let result = db.RunCommand<InsertResult>(JsonCommand userscmd)
    printfn $"InsertResult: %A{result}"

    let over20 = getUsersOverAge 20
    let result = db.RunCommand<FindResult<User>>(JsonCommand over20)
    printfn $"FindResult Ok: %f{result.ok}"
    result.cursor.firstBatch |> Seq.iter (fun value -> printfn $"%A{value}")

    let updatecmd = updateUser "Updateme" "Updated"
    let result = db.RunCommand<UpdateResult>(JsonCommand updatecmd)
    printfn $"UpdateResult: %A{result}"

    let deletecmd = deleteUser "Deleteme"
    let result = db.RunCommand<DeleteResult>(JsonCommand deletecmd)
    printfn $"DeleteResult: %A{result}"

    0

If you want to see what else is available check the samples directory

Documentation

Right now the documentation is provided via .NET Interactive notebooks. There are three ways ways to ineract with it

  • The Notebooks directory contains jupyter notebooks that you can download and open them with the VSCode Extension to interact with them in real time.

  • If you don't want to download anything you can still check the notebooks online, click on Binder to go to the binder website and check the notebooks online

  • If your editor supports doc comments, you should be able to see samples as well, part of the source code is documented that way, you should even see examples in the editor tooltips in some cases

Goals

Non Required Extras

  • provide helpers to write different syntax (e.g. filter (fun m -> m.prop = value), filter ("prop" gt 10))

Non Goals

  • Convert this into a document mapper
  • Provide 100% of the mongo commands
  • Provide a 100% F# idiomatic solution

This is a work in progress, you can help providing feedback about it's usage

Thanks for the early feedback in twitter from Isaac, Zaid, Alexey, Alexander, and the F# community you can follow it on the first issue

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].