🚀 The Rapid and Delightful Kotlin Web Framework. Easy, elegant, and productive!
intended()
and previousUrl()
. These methods are also available on an HttpCall
object.inRandomOrder()
, for fetching entities in random order from a MySQL database.render()
and json()
methods with ArgsBuilder
as a lambda receiver.HttpCall.entityParam()
extension method that fetches an entity from a table by looking up an id
route param.spoof()
view function. (Resolves #27).CompletableFuture
.intReference()
and longReference()
as shortcuts for defining referencing columns.useCurrent
attribute is set to false
for bothcreatedAt()
and updatedAt()
.This release brings even more exciting features and improvements to Alpas. Here are the highlights:
You can create a resourceful routes for all the CRUD operations by using resources()
method:
resources<PostController>("posts").name("posts")
In dev mode Alpas automatically selects the next port if the selected port is in use already. Docs.
Few useful methods and conventions are added in Ozone such as findOrCreate(attrs)
, findOne(attrs)
, findMany()
, update(attrs)
, reference()
etc. Docs.
Also added are four new column bindings - createdAt()
, updatedAt()
, increments()
, bigIncrements()
.
Docs.
This means instead of this:
val id by bigInt("id").autoIncrement().unsigned().primaryKey().bindTo{ it.id }
val createdAt by timestamp("created_at").nullable().useCurrent().bindTo { it.createdAt }
val updatedAt by timestamp("updated_at").nullable().useCurrent().bindTo { it.updatedAt }
You can do this:
val id by bigIncrements()
val createdAt by createdAt()
val updatedAt by updatedAt()
In dev mode, routes are now reloaded without restarting the app. For performance reason this is disabled in the prod mode.
This allows to run migrations even from a fat jar. Very helpful in production.
You can now addColumn()
and dropColumn()
You can now add a reference constraint on a column:
val userId by long("user_id").belongsTo(Users) { it.user }.unsigned().reference { onDeleteCascade() }
--seed
flag.
val user = from(UserFactory) {
it.name to "Jane M. Doe"
it.email to "[email protected]"
}
There are few but significant breaking changes in this release:
Entity
has been renamed to OzoneEntity
and MigratingTable
has been renamed to OzoneTable
:// Before: interface User : Entity<User>
// Now:
interface User : OzoneEntity<User> {
// ...
// Before: companion object : Entity.Factory<User>
// Now:
companion object : OzoneEntity.Of<User>()
}
// Before: object Users : MigratingTable<User>
// Now:
object Users : OzoneTable<User>("users") {
// ...
}
EntityFactory
now takes two parameters instead of one:
// Before: class UserFactory() : EntityFactory<User>()
// Now:
class UserFactory() : EntityFactory<User, Users>() {
// ...
}
onlyParams()
method has been renamed to params()
paramAsString()
method is now stringParam()
paramAsInt()
is now intParam()
paramAsLong()
is now longParam()
paramAsBool()
is now boolParam()
Packed with so many new features and improvements, this release is probably the biggest and the most exciting release since the initial public release few weeks ago.
make:factory
command.make:seeder
and db:seed
commands.link:web
for instant refreshing of assets without recompiling.link:templates
for instant refreshing of templates without recompiling (even in the production mode!).Environment
class such as storagePath()
, rootPath()
, etc.hasMany
and belongsTo
methods to fetch related models intuitively. They are also cached for performance reasons.CreateTable
is still not supported.PostgresqlConnection
class to start connecting with a Postgres database with much fuss.Console commands listing is now colored. Coloring has been improved for other console outputs as well.
Routing is even more strongly typed and even more compact without compromising the readability. No more magic strings.
// before
get("/", HomeController::class, "index")
// now
get("/", HomeController::index)
// And of course, you can shorten it to
get<HomeController>()
kotlinOptions.jvmTarget = "9"
in your build.gradle file.🙏 Thanks to @racharya @armgitaar @vanessagertman @damien-roche @vincentlauvlwj for their help to make this release possible.