Skip to content

Releases: steebchen/prisma-client-go

v0.9.0

20 May 16:11
315c235
Compare
Choose a tag to compare

v0.9.0

Go1.16 support & bugfixes

🌟 Help us spread the word about Prisma by starring the repo ☝️ or tweeting about the release.

Major changes

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.

Changes

Contributors

@alfuhigi, @matthewmueller and @steebchen

Interested in providing feedback for the Go client?

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.

v0.8.0

05 May 14:57
d6f0f1b
Compare
Choose a tag to compare

v0.8.0

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.

Major changes

Changes

Contributors

@steebchen

Interested in providing feedback for the Go client?

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.

v0.7.0

01 Apr 14:26
a7eef73
Compare
Choose a tag to compare

v0.7.0

More native types & bugfixes

🌟 Help us spread the word about Prisma by starring the repo ☝️ or tweeting about the release.

Major changes

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)

Changes

Contributors

@Jolg42 and @steebchen

Interested in providing feedback for the Go client?

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.

v0.6.0

22 Mar 10:38
2aafba4
Compare
Choose a tag to compare

v0.6.0

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.

Breaking changes

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)
}

Major changes

Changes

Contributors

@matthewmueller and @steebchen

Extra thanks to @robojones for the help with transaction syntax!

Interested in providing feedback for the Go client?

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.

v0.5.0

05 Mar 07:12
3f2a8a4
Compare
Choose a tag to compare

v0.5.0

Tons of bugfixes & Upsert!

🌟 Help us spread the word about Prisma by starring the repo ☝️ or tweeting about the release.

Major changes

UpsertOne

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)
}

Changes

Contributors

@bshihr, @imkh and @steebchen

Interested in providing feedback for the Go client?

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.

v0.4.1

09 Feb 20:00
0b69d80
Compare
Choose a tag to compare

v0.4.1

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.

Changes

  • feat(prisma): upgrade prisma to 2.16.1 patch release (#392) @steebchen

Contributors

@steebchen

Interested in providing feedback for the Go client?

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.

v0.4.0

04 Feb 17:13
027614c
Compare
Choose a tag to compare

v0.4.0

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.

Major changes

Dynamically build queries

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.

ExecInner helper method

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)

Breaking changes

All methods returning structs now return a pointer to a struct

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)

Methods returning a primitive value such as count now returns struct

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)

Embedded model structs InternalX are renamed to InnerX

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)

Changes

Contributors

@steebchen

Interested in providing feedback for the Go client?

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.

v0.3.0

21 Jan 15:43
8fe9924
Compare
Choose a tag to compare

v0.3.0

  • Introduces basic transactions
  • Introduces FindFirst
  • FindOne is deprecated in favour of FindUnique
  • There's also a new Prisma namespace for Prisma-related functions.

🌟 Help us spread the word about Prisma by starring the repo ☝️ or tweeting about the release.

Major changes

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(…)

Changes

Contributors

@steebchen

Interested in providing feedback for the Go client?

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.

v0.2.0

07 Dec 13:45
22b80ca
Compare
Choose a tag to compare

v0.2.0

JSON support, native mocks, helper methods & minor improvements

🌟 Help us spread the word about Prisma by starring the repo ☝️ or tweeting about the release.

Major changes

Changes

Contributors

@steebchen

Interested in providing feedback for the Go client?

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.

v0.1.0

09 Nov 17:11
041b891
Compare
Choose a tag to compare

v0.1.0

Go client early access

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.

Release Notes

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.

Major changes

  • bump internal Prisma CLI to 2.10.2 (#290, #291)
  • improve docs (#284)
  • fix .Link() method parameters (#288)

Changes

Contributors

@steebchen

Interested in providing feedback for the Go client?

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.