Skip to content

Missing modelSlice methods? #310

Answered by stephenafamo
jalaziz asked this question in Q&A
Discussion options

You must be logged in to vote

The docs definitely need to be updated.
There have been quite a few large changes recently, and the docs have not been updated to match.

The CHANGELOG also has a mistake....

Insert

Old way

Previously you could insert a slice of Setters with table.Insert and table.InsertMany:

user, err := models.Users.Insert(ctx, db, setter) // insert one
users, err := models.Users.InsertMany(ctx, db, setters...) // insert many

New way

Now, each setter is an insert mod by itself:

user, err := models.Users.Insert(setter).One(ctx, db) // insert one
users, err := models.Users.Insert(setters[0], setters[1]).All(ctx, db) // insert many


// For cases where you already have a slice of setters and you want to pas…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@jalaziz
Comment options

@stephenafamo
Comment options

Answer selected by stephenafamo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants