Make sure that you’ve imported Sugar everywhere when needed:
import Sugar
Helpers
This package contains a lot of misc. functionality that might not fit into it’s own package or that would best to get PR’ed into Vapor. Some examples of what this package contains:
Environment variables
Access environment variables by writing
env("my-key", "my-fallback-value")
Seeder commands
If you want to make your model seedable, you can conform it to Seedable and use SeederCommand to wrap your seedable model. This basically means that you can focus on how your model gets initialized when running your command, and save a little code on actually performing the database work.
Seeding multiple instances of your model will be added - feel free to PR.
Authentication
This package contains a lot of convenience related to JWT, usernames and passwords which is used in JWTKeychain and Admin Panel.
Migrations
Sugar contains a helper function for adding properties while excluding some specific ones. This makes it a bit more convenient if you want to only modify how a single one or a couple of fields gets prepared.
Sugar 🍬
📦 Installation
Add
Sugar
to the package dependencies (in yourPackage.swift
file):as well as to your target (e.g. “App”):
Getting started 🚀
Make sure that you’ve imported Sugar everywhere when needed:
Helpers
This package contains a lot of misc. functionality that might not fit into it’s own package or that would best to get PR’ed into Vapor. Some examples of what this package contains:
Environment variables
Access environment variables by writing
Seeder commands
If you want to make your model seedable, you can conform it to
Seedable
and useSeederCommand
to wrap your seedable model. This basically means that you can focus on how your model gets initialized when running your command, and save a little code on actually performing the database work.Authentication
This package contains a lot of convenience related to JWT, usernames and passwords which is used in JWTKeychain and Admin Panel.
Migrations
Sugar contains a helper function for adding properties while excluding some specific ones. This makes it a bit more convenient if you want to only modify how a single one or a couple of fields gets prepared.
🏆 Credits
This package is developed and maintained by the Vapor team at Nodes.
📄 License
This package is open-sourced software licensed under the MIT license