Get inserted data in Create().After hook, especially PrimaryKayValue

Description

It would easliy implement in gormV1,

    db.Callback().Create().After("gorm:create").Register(hookName, func(scope *gorm.Scope) {
        fmt.Printf("Inserted entities of %s with %s=%v\n", scope.TableName(), scope.PrimaryKey(), scope.PrimaryKeyValue())
        entries = append(entries, entity{table: scope.TableName(), keyname: scope.PrimaryKey(), key: scope.PrimaryKeyValue()})
    })

but gorm.Scope was removed in gormV2, so I don't known how to do this.

now I can get the tablename, and primary key name, but have no idea about PrimaryKeyValue

tableName := db.Statement.Table
pk := db.Statement.Schema.PrioritizedPrimaryField.Name

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: a631807682

refer to https://github.com/go-gorm/gorm/blob/master/callbacks/create.go#L137