Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gopg: exclude column when upserting records #6

Open
v36372 opened this issue Jun 24, 2024 · 0 comments
Open

gopg: exclude column when upserting records #6

v36372 opened this issue Jun 24, 2024 · 0 comments

Comments

@v36372
Copy link
Owner

v36372 commented Jun 24, 2024

This will update all fields

db.Model(&models).OnConflict("(conflicted_fields) DO UPDATE").Insert()

This will update the specified fields

db.Model(&models).
    OnConflict("(conflicted_fields) DO UPDATE").
    Set("models.a = EXCLUDED.a"). 
    Insert()

This will update all fields except a

db.Model(&models).
    OnConflict("(conflicted_fields) DO UPDATE").
    ExcludeColumn("a").
    Insert()
@v36372 v36372 changed the title gopg: exclude column when updating records gopg: exclude column when upserting records Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant