All Projects → OpenKitten → MeowVapor

OpenKitten / MeowVapor

Licence: other
Meow plugin for API generation

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to MeowVapor

Fluent
Vapor ORM (queries, models, and relations) for NoSQL and SQL databases
Stars: ✭ 1,071 (+8825%)
Mutual labels:  orm, vapor
sequelize-adapter
Sequelize adapter for Casbin
Stars: ✭ 51 (+325%)
Mutual labels:  orm
java-bible
🍌 我的技术摘要
Stars: ✭ 2,950 (+24483.33%)
Mutual labels:  orm
catbird
Mock server for UI tests
Stars: ✭ 32 (+166.67%)
Mutual labels:  vapor
pinipig
🚀 Performant webservice framework
Stars: ✭ 25 (+108.33%)
Mutual labels:  orm
gobatis
golang mybatis, 简单便捷
Stars: ✭ 46 (+283.33%)
Mutual labels:  orm
easy-es
Better Elastic Search search engine framework, the bottom layer adopts RestHighLevelClient, API design consistent with Mybatis-plus, zero additional learning cost, shielding language differences, developers only need to know MySQL syntax to complete Es-related operations, both Low code, easy to use, easy to expand and other features, support Es …
Stars: ✭ 218 (+1716.67%)
Mutual labels:  orm
email
A common API for Vapor to integrate with different email providers
Stars: ✭ 13 (+8.33%)
Mutual labels:  vapor
ormdb
ORM tool for .Net / .Net.Core
Stars: ✭ 14 (+16.67%)
Mutual labels:  orm
sanic-mongodb-extension
MongoDB with μMongo support for Sanic framework
Stars: ✭ 25 (+108.33%)
Mutual labels:  orm
feathers-objection
Feathers database adapter for Objection.js, an ORM based on KnexJS SQL query builder for Postgres, Redshift, MSSQL, MySQL, MariaDB, SQLite3, and Oracle. Forked from feathers-knex.
Stars: ✭ 89 (+641.67%)
Mutual labels:  orm
gene
Grace, fastest, flexibility, simple PHP extension framework!优雅、极速、灵活、简单的PHP扩展框架!
Stars: ✭ 30 (+150%)
Mutual labels:  orm
gorm-hibernate5
GORM for Hibernate 5
Stars: ✭ 51 (+325%)
Mutual labels:  orm
mocka
Mocka — A Mock Server Made for Developers by Developers, made in Swift ❤️
Stars: ✭ 56 (+366.67%)
Mutual labels:  vapor
eloquent-mongodb-repository
Eloquent MongoDB Repository Implementation
Stars: ✭ 18 (+50%)
Mutual labels:  orm
laravel-msaccess
Laravel ORM for Microsoft Access DB
Stars: ✭ 31 (+158.33%)
Mutual labels:  orm
heliosRX
⚡️ The fast way to build real-time apps with Vue and Firebase 🔥
Stars: ✭ 23 (+91.67%)
Mutual labels:  orm
MyDAL
The fastest and best ORM lite on C# for MySQL ! -- 友好, 轻量, 极致性能, 无任何第三方依赖, 持续演进~~
Stars: ✭ 32 (+166.67%)
Mutual labels:  orm
doctrine-json-odm
JSON Object-Document Mapping bundle for Symfony and Doctrine
Stars: ✭ 15 (+25%)
Mutual labels:  orm
postgres-kit
🐘 Non-blocking, event-driven Swift client for PostgreSQL.
Stars: ✭ 125 (+941.67%)
Mutual labels:  vapor

🐈 MeowVapor

MeowVapor bridges Meow to Vapor and provides awesome helpers for creating a Meow based Vapor app/API.

Add the dependency

.package(url: "https://github.com/OpenKitten/MeowVapor.git", from: "2.0.0")

Add MeowVapor as a dependency via SPM and run swift package update.

Setting up

Add Meow to your Vapor services. Be sure to change the MongoDB URI to point to your server.

let meow = try MeowProvider(uri: "mongodb://localhost/MyDatabase")
try services.register(meow)

Using MeowVapor

router.get { request -> Future<[User]> in
   let context = try request.make(Meow.Context.self)
   return context.find(User.self).getAllResults()
}

Creating models

When creating a Model you need to conform your class to Model. The only requirement is that you add a property to your model with a key of _id and is not a computed property.

final class User: Model {
  var _id = ObjectId()
  
  ...
}

You can use any type for the _id key as long as it's a standard BSON Primitive type including:

  • ObjectId
  • String
  • Double
  • Int
  • Int32
  • Binary / Data

The following is completely legitimate:

// Stores the username in _id
final class User: Model {
  var _id: String
  
  var username: String {
    return _id
  }
  
  ...

By default the model name will be used for the collection name. You can customize this with a static let collectionName: String

final class User: Model {
  // Changes the collection name from `User` to `users`
  static let collectionName = "users"

  var _id = ObjectId()
  
  ...

Queries

Queries reside within the Context.

References

final class Article: Model {
  var _id = ObjectId()
  let creator: Reference<User>
  var title: String
  var text: String
  
  ...

The above demonstrates how a simple reference can be created to another model. In this case a User model. And below demonstrates resolving the reference.

let resolvedUser = article.creator.resolve(in: context)

The result in this case is an EventLoopFuture<User>, but if you wish to resolve the reference's target to nil if it doesn't exist you can simply do article.creator.resolveIfPresent(in: context).

You're also able to delete the target of the reference using reference.deleteTarget(in: context). This implies that resolving the normal way (not with ifPresent) will result in a failure.

Unsupported MongoDB features

If a feature is unsupported by Meow, for example when it can't be type-safe, you can always fall back to MongoKitten.

let database: MongoKitten.Database = context.manager.database

🐈 Community

Join our slack here and become a part of the welcoming community.

⭐️ Features

  • Boilerplate-free
  • So easy it will make you purr, or have your money back!
  • Awesome type-safe and autocompleted queries
  • Support for custom MongoDB queries
  • Easy migrations to a new model version
  • Supports your own types (like structs and enums) and common types (like String, Int and Date) out of the box using Codable
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].