VOOZH about

URL: https://www.nuget.org/packages/SquirrelFramework.MongoDB/

⇱ NuGet Gallery | SquirrelFramework.MongoDB 2.0.0




👁 Image
SquirrelFramework.MongoDB 2.0.0

dotnet add package SquirrelFramework.MongoDB --version 2.0.0
 
 
NuGet\Install-Package SquirrelFramework.MongoDB -Version 2.0.0
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SquirrelFramework.MongoDB" Version="2.0.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SquirrelFramework.MongoDB" Version="2.0.0" />
 
Directory.Packages.props
<PackageReference Include="SquirrelFramework.MongoDB" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SquirrelFramework.MongoDB --version 2.0.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SquirrelFramework.MongoDB, 2.0.0"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SquirrelFramework.MongoDB@2.0.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SquirrelFramework.MongoDB&version=2.0.0
 
Install as a Cake Addin
#tool nuget:?package=SquirrelFramework.MongoDB&version=2.0.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

SquirrelFramework.MongoDB 2.0.0

Squirrel Framework - A lightweight back-end framework and utilities kit based on MongoDB.

The word Squirrel has the meaning of squirrels and storage. The Squirrel Framework is working to make your MongoDB / Azure Cosmos DB-based applications lightweight and fast.

Dependencies Description

Release notes: 2.0.0 (Chinese, 中文)

Release notes: 1.0.15 (Chinese, 中文)

Release notes: 1.0.14 (Chinese, 中文)

Quick Start (Chinese, 中文)

Get Package

You can get the latest stable release from the official Nuget.org feed

https://www.nuget.org/packages/SquirrelFramework.MongoDB

Getting Started

  1. Create a .NET project, please ensure that the target framework MUST be .NET 6 or later

  2. Get the Nuget package by searching the keyword "SquirrelFramework.MongoDB" or using the Project Manager

    Install-Package SquirrelFramework.MongoDB -Version 2.0.0
    
  3. Create your Domain Model

    using SquirrelFramework.Domain.Model;
    
    [Database("YourDatabaseName")]
    [Collection("UsersCollectionName")]
    public class User : DomainModel
    {
     public string Name { get; set; }
     public string Gender { get; set; }
     public int Age { get; set; }
    }
    

    The [Database] attribute is not necessary, you can set the default MongoDB database name when initialing the configurations.

    Configurations.Configure("mongodb://localhost:27017", "Test");
    MongoDBBasicTestCrudRepository = new MongoDBBasicTestCrudRepository();
    var pingResult = MongoDBBasicTestCrudRepository.Ping();
    Console.WriteLine(pingResult);
    

    Since 1.0.14 the [Collection] attribute is no longer required. If you not specified the [Collection] attribute, the Squirrel Framework use the class name as the collection name.

  4. Create your Repository for MongoDB CRUD

    using SquirrelFramework.Repository;
    
    public class UserRepository: RepositoryBase<User> {}
    
  5. Now you are free to perform various operations on MongoDB, here are some examples

     var userRepo = new UserRepository();
    
    • Add a new user record

       userRepo.Add(new User{
       Name = "Hendry",
       Gender = "Male",
       Age = 18,
       Geolocation = new Geolocation(121.551949, 38.890957)
       });
      
    • Get all users who are 2 kilometers away from me

       userRepo.GetNearBy(new Geolocation(121.551949, 38.890957), 2000);
      
    • Bulk delete users who are older than 25 asynchronously

       userRepo.DeleteManyAsync(u => u.Age > 25);
      
    • Get the third page (15 records) of all user data and descending sort by the Age field

       // Method signature
       // public IEnumerable<TDomain> GetAllByPageSortBy(
       // int pageIndex,
       // int pageSize,
       // Expression<Func<TDomain, object>> sortBy,
       // bool isSortByDescending = false
       // );
      
       userRepo.GetAllByPageSortBy(2, 15, u => u.Age, true);
      
  6. If your data collection is dynamic, for example you have multiple collections to store your user information:

    • Users201801
    • Users201802
    • Users201803
    • ...

    You can use the CustomizedRepositoryBase class as a base class

     public class UserRepository: CustomizedRepositoryBase<User> {}
    

    Then you can provide the specific collection name for each CRUD operation.

    • Add a new user record
       var userRepo = new UserRepository();
       userRepo.Add("Users201805", new User{
       Name = "George",
       Gender = "Male",
       Age = 18,
       Geolocation = new Geolocation(121.551949, 38.890957)
       });
      
  7. Create your Domain Service (This is not a necessary step)

     public class UserService : ServiceBase<User, UserRepository> {}
    

Contributing

  • George Qi me@nap7.com

If you have any questions, please feel free to contact me

Product Versions Compatible and additional computed target framework versions.
.NET net7.0 net7.0 is compatible.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 424 5/27/2023
0.9.2 751 7/7/2020