Prisma Client Go is an auto-generated and fully type-safe database client
APACHE-2.0 License
Bot releases are visible (Hide)
Published by github-actions[bot] about 3 years ago
THIS RELEASE CONTAINS BREAKING CHANGES!
Please read the release notes of Prisma 3.x https://github.com/prisma/prisma/releases/tag/3.0.1 which contains many different breaking changes, the primary one being referential actions which breaks previous behaviour. You might want to to checkout the upgrade path for referential actions.
This release currently uses the latest Prisma version https://github.com/prisma/prisma/releases/tag/3.1.1.
Note: This release currently does not support MongoDB.
π Help us spread the word about Prisma by starring the repo βοΈ or tweeting about the release.
Enable it in your Go project by adding the fullTextSearch
preview feature.
generator db {
provider = "go run github.com/prisma/prisma-client-go"
+ previewFeatures = ["fullTextSearch"]
}
// Fetch all drafts with a title that contains the words fox or dog
posts, _ := client.Post.FindMany(
db.Post.Title.Search("fox | dog"),
db.Post.Status.Equals("Draft"),
).Exec(context.Background())
// Loop over the posts and print the title
for _, post := range posts {
fmt.Println(post.Title)
}
@Looskie, @hi019 and @steebchen
We would like to ask you a few questions and get your feedback about the Go client. We'll send merch along your away as a thank you.
If you're interested, email me at [email protected] or join our public Slack and DM me.
Published by github-actions[bot] over 3 years ago
Basic support for .env files + some minor bugfixes around transactions & postgres list fields
π Help us spread the word about Prisma by starring the repo βοΈ or tweeting about the release.
@steebchen
We would like to ask you a few questions and get your feedback about the Go client. We'll send merch along your away as a thank you.
If you're interested, email me at [email protected] or join our public Slack and DM me.
Published by github-actions[bot] over 3 years ago
Go1.16 support & bugfixes
π Help us spread the word about Prisma by starring the repo βοΈ or tweeting about the release.
Go1.16 requires go.mod/go.sum to be up-to-date and that broke for generated code, as go mod tidy can't figure out what modules are needed before generating code. This is fixed by adding no-op imports in the Go client at a top-level, so they can be detected by Go modules correctly.
@alfuhigi, @matthewmueller and @steebchen
We would like to ask you a few questions and get your feedback about the Go client. We'll send merch along your away as a thank you.
If you're interested, email me at [email protected] or join our public Slack and DM me.
Published by github-actions[bot] over 3 years ago
Bugfixes & add AND
operator.
Upgrades to Prisma 2.22.0, making the db push
command generally available.
π Help us spread the word about Prisma by starring the repo βοΈ or tweeting about the release.
@steebchen
We would like to ask you a few questions and get your feedback about the Go client. We'll send merch along your away as a thank you.
If you're interested, email me at [email protected] or join our public Slack and DM me.
Published by github-actions[bot] over 3 years ago
More native types & bugfixes
π Help us spread the word about Prisma by starring the repo βοΈ or tweeting about the release.
The Go client now supports the native types Bytes, BigInt and Decimal:
var views db.BigInt = 1
bytes := []byte("abc")
dec := decimal.NewFromFloat(1.23456789)
created, err := client.User.CreateOne(
db.User.Picture.Set(bytes),
db.User.Balance.Set(dec),
db.User.Views.Set(views),
).Exec(ctx)
@Jolg42 and @steebchen
We would like to ask you a few questions and get your feedback about the Go client. We'll send merch along your away as a thank you.
If you're interested, email me at [email protected] or join our public Slack and DM me.
Published by github-actions[bot] over 3 years ago
Apart from lots of bugfixes, this release also introduces transaction return values:
firstPost := client.Post.CreateOne(
Post.Title.Set("First Post"),
).Tx()
secondPost := client.Post.CreateOne(
Post.Title.Set("Second Post"),
).Tx()
if err := client.Prisma.Transaction(firstPost, secondPost).Exec(ctx); err != nil {
panic(err)
}
log.Printf("first post result: %+v", firstPost.Result())
log.Printf("second post result: %+v", secondPost.Result())
π Help us spread the word about Prisma by starring the repo βοΈ or tweeting about the release.
When using transactions, you need to explicitly call .Tx() in each operation.
before:
firstPost := client.Post.CreateOne(
Post.Title.Set("First Post"),
)
secondPost := client.Post.CreateOne(
Post.Title.Set("Second Post"),
)
if err := client.Prisma.Transaction(firstPost, secondPost).Exec(ctx); err != nil {
panic(err)
}
after:
firstPost := client.Post.CreateOne(
Post.Title.Set("First Post"),
).Tx()
secondPost := client.Post.CreateOne(
Post.Title.Set("Second Post"),
).Tx()
if err := client.Prisma.Transaction(firstPost, secondPost).Exec(ctx); err != nil {
panic(err)
}
Into(interface{})
method for QueryRaw (#438) @steebchen@matthewmueller and @steebchen
Extra thanks to @robojones for the help with transaction syntax!
We would like to ask you a few questions and get your feedback about the Go client. We'll send merch along your away as a thank you.
If you're interested, email me at [email protected] or join our public Slack and DM me.
Published by github-actions[bot] over 3 years ago
Tons of bugfixes & Upsert!
π Help us spread the word about Prisma by starring the repo βοΈ or tweeting about the release.
post, err := client.Post.UpsertOne(
// query
Post.ID.Equals("upsert"),
).Create(
// set these fields if document doesn't exist already
Post.Title.Set("title"),
Post.Views.Set(0),
Post.ID.Set("upsert"),
).Update(
// update these fields if document already exists
Post.Title.Set("new-title"),
Post.Views.Increment(1),
).Exec(ctx)
if err != nil {
panic(err)
}
@bshihr, @imkh and @steebchen
We would like to ask you a few questions and get your feedback about the Go client. We'll send merch along your away as a thank you.
If you're interested, email me at [email protected] or join our public Slack and DM me.
Published by github-actions[bot] over 3 years ago
A patch release for [email protected].
This fixes some connectivity issues with MySQL/SQL Server.
π Help us spread the word about Prisma by starring the repo βοΈ or tweeting about the release.
@steebchen
We would like to ask you a few questions and get your feedback about the Go client. We'll send merch along your away as a thank you.
If you're interested, email me at [email protected] or join our public Slack and DM me.
Published by github-actions[bot] over 3 years ago
Dynamically build queries, helper methods, some BREAKING CHANGES (see below)
π Help us spread the word about Prisma by starring the repo βοΈ or tweeting about the release.
Give your users more control over how they filter and order their data. Build up filters over time instead of all at once.
Here's an example of setting specific attributes dynamically:
func CreateUser(w http.ResponseWriter, r *http.Request) {
var params []db.UserSetParam
email := r.PostFormValue("email")
kind := r.PostFormValue("kind")
if kind == "customer" {
// Set the referrer for users of type customer only
params = append(params, db.User.Referer.Set(r.Header.Get("Referer"))
}
user, err := client.User.CreateOne(
db.User.Kind.Set(kind),
db.User.Email.Set(email),
params...,
).Exec(r.Context())
// ... Handle the response
}
Learn more in the dynamic queries document.
Prisma uses a specific structure for its models. For some libraries, you might need a struct with pointer values instead of Prismaβs embedded structure.
For this case, you can use the .InnerX embedded structs to get the plain object. However, there was no method for results with slices before, so we introduced ExecInner:
users, err := client.User.FindMany().ExecInner(ctx)
doSomething(users)
Methods in shape of (T, error) now return (*T, error):
user, err := client.User.FindMany().Exec(ctx)
// user was of type db.UserModel
// user is now of type *db.UserModel
log.Printf(βuser: %+vβ, *user)
For more consistency, all methods which used to return a count-like value now return a pointer to a struct.
result, err := client.User.FindMany().Update(β¦).Exec(ctx)
// result was of type int before
// result is now a pointer to a struct
log.Printf(βuser: %dβ, result.Count)
This affects the following methods:
client.X.FindMany().Update().Exec(ctx)
client.X.FindMany().Delete().Exec(ctx)
client.ExecuteRaw(β¦).Exec(ctx)
Internal might be misleading as itβs recommended to use the top-level return value wherever possible, but with some libraries you might need to use the embedded struct, so we renamed it to Inner to make it more clear what it does.
user, err := client.User.FindUnique()
// was called user.InternalUser before
// now is called user.InnerUser
doSomething(user.InnerUser)
@steebchen
We would like to ask you a few questions and get your feedback about the Go client. We'll send merch along your away as a thank you.
If you're interested, email me at [email protected] or join our public Slack and DM me.
Published by github-actions[bot] over 3 years ago
FindFirst
FindOne
is deprecated in favour of FindUnique
Prisma
namespace for Prisma-related functions.π Help us spread the word about Prisma by starring the repo βοΈ or tweeting about the release.
Introducing transactions: run multiple statements at once, guaranteeing that everything as a whole either fails or succeeds.
createUserA := client.User.CreateOne(
User.Email.Set("a"),
User.ID.Set("a"),
)
createUserB := client.User.CreateOne(
User.Email.Set("b"),
User.ID.Set("b"),
)
if err := client.Prisma.Transaction(createUserA, createUserB).Exec(ctx); err != nil {
panic(err)
}
FindOne is deprecated. It's renamed to FindUnique.
To find a record which is not guaranteed to be unique, you can now use the new FindFirst method to use the first element which is found:
post, err := client.Post.FindFirst(
db.Post.Title.Equals("hi"),
).Exec(ctx)
if errors.Is(err, db.ErrNotFound) {
log.Printf("no record with title 'hi' found")
} else if err != nil {
log.Printf("error occurred: %s", err)
}
log.Printf("post: %+v", post)
All Prisma-related functions on the prisma client object are deprecated in favour of a new prisma namespace.
The following methods:
client := prisma.NewClient()
client.Connect(β¦)
client.Disconnect(β¦)
client.ExecuteRaw(β¦)
client.QueryRaw(β¦)
Should be used as follows:
client := prisma.NewClient()
client.Prisma.Connect(β¦)
client.Prisma.Disconnect(β¦)
client.Prisma.ExecuteRaw(β¦)
client.Prisma.QueryRaw(β¦)
@steebchen
We would like to ask you a few questions and get your feedback about the Go client. We'll send merch along your away as a thank you.
If you're interested, email me at [email protected] or join our public Slack and DM me.
Published by github-actions[bot] almost 4 years ago
JSON support, native mocks, helper methods & minor improvements
π Help us spread the word about Prisma by starring the repo βοΈ or tweeting about the release.
IfPresent
method variants (#300) @steebchen@steebchen
We would like to ask you a few questions and get your feedback about the Go client. We'll send merch along your away as a thank you.
If you're interested, email me at [email protected] or join our public Slack and DM me.
Published by github-actions[bot] almost 4 years ago
The Go client is now an early access product and is not considered experimental anymore. π
This means we will continue to invest in the Go client, but at the same time those resourced will be limited and we may have breaking changes in minor releases.
This release contains minor improvements and bumps the internal Prisma CLI to 2.10.2.
π Help us spread the word about Prisma by starring the repo βοΈ or tweeting about the release.
.Link()
method parameters (#288)@steebchen
We would like to ask you a few questions and get your feedback about the Go client. We'll send merch along your away as a thank you.
If you're interested, email me at [email protected], join our public Slack, or schedule a call directly with us.
Published by github-actions[bot] about 4 years ago
Tons of bugfixes, minor improvements, docs updates... and number type operations!
post, err := client.Post.FindOne(
Post.ID.Equals("a"),
).Update(
Post.IntField1.Increment(3),
Post.FloatField2.Decrement(2.5),
Post.IntField3.Multiply(2),
Post.FloatField4.Divide(1.5),
).Exec(ctx)
π Help us spread the word about Prisma by starring the repo βοΈ or tweeting about the release.
@FranciscoMendes10866, @janpio, @jaymecd and @steebchen
We would like to ask you a few questions and get your feedback about the Go client. We'll send merch along your away as a thank you.
If you're interested, email me at [email protected] or join our public Slack and DM me.
Published by github-actions[bot] about 4 years ago
This upgrades the Prisma CLI to 2.7.1.
It's known that this release currently doesn't work on windows. If you need windows support, please stay on v0.0.8 and follow the windows support tracking issue.
@steebchen
Published by github-actions[bot] about 4 years ago
A small release containing bugfixes and documentation updates.
@satishbabariya and @steebchen
Published by github-actions[bot] about 4 years ago
A small patch release to adapt the naming of generated query engine go files, plus clean up some old documentation.
The generated go query engine files are now named query-engine-{platform}_gen.go
, and the automatically generated gitignore is adapted as well.
@steebchen
Published by github-actions[bot] about 4 years ago
Upgrades Prisma to its stable version 2.0.0 and introduces a new pagination API as well as differences in the raw API. We also renamed internal structs from "RawX" to "InternalX" to prevent confusion with the SQL raw API.
@steebchen
Published by github-actions[bot] about 4 years ago
Binary files refactor. The prisma go client uses the prisma query engine internally.
Instead of fetching the query engine on runtime, it is now fetched on generate time into the user's project dir.
The correct binary is picked up by go build using build constraints. There will also be a .gitignore generated into the output dir so that the generated prisma client and the query engine files are ignored by default.
The output field in the schema.prisma file now accepts a folder instead of a file.
@steebchen
Published by github-actions[bot] over 4 years ago
Bug fixes and docs improvements.
@brenelz, @matthewmueller and @steebchen
Published by github-actions[bot] over 4 years ago
This release adds alpine support, improves code constraints, adds features, and provides various bugfixes.
package
option in schema.prisma to override).Unlink()
method (#173) @steebchen@Jolg42 and @steebchen