Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 3 of 3 for CreateInBatches (0.05 sec)

  1. tests/generics_test.go

    		{Name: "GenericsCreateInBatches1"},
    		{Name: "GenericsCreateInBatches2"},
    		{Name: "GenericsCreateInBatches3"},
    	}
    	ctx := context.Background()
    
    	if err := gorm.G[User](DB).CreateInBatches(ctx, &batch, 2); err != nil {
    		t.Fatalf("CreateInBatches failed: %v", err)
    	}
    
    	for _, u := range batch {
    		if u.ID == 0 {
    			t.Fatalf("no primary key found for %v", u)
    		}
    	}
    
    Registered: Sun Sep 07 09:35:13 UTC 2025
    - Last Modified: Thu Sep 04 13:13:16 UTC 2025
    - 28K bytes
    - Viewed (0)
  2. generics.go

    	})}
    }
    
    func (c createG[T]) Create(ctx context.Context, r *T) error {
    	return c.g.apply(ctx).Create(r).Error
    }
    
    func (c createG[T]) CreateInBatches(ctx context.Context, r *[]T, batchSize int) error {
    	return c.g.apply(ctx).CreateInBatches(r, batchSize).Error
    }
    
    type chainG[T any] struct {
    	execG[T]
    }
    
    func (c chainG[T]) getInstance() *DB {
    	var r T
    Registered: Sun Sep 07 09:35:13 UTC 2025
    - Last Modified: Thu Sep 04 13:13:16 UTC 2025
    - 15.5K bytes
    - Viewed (0)
  3. finisher_api.go

    func (db *DB) Create(value interface{}) (tx *DB) {
    	if db.CreateBatchSize > 0 {
    		return db.CreateInBatches(value, db.CreateBatchSize)
    	}
    
    	tx = db.getInstance()
    	tx.Statement.Dest = value
    	return tx.callbacks.Create().Execute(tx)
    }
    
    // CreateInBatches inserts value in batches of batchSize
    func (db *DB) CreateInBatches(value interface{}, batchSize int) (tx *DB) {
    	reflectValue := reflect.Indirect(reflect.ValueOf(value))
    
    Registered: Sun Sep 07 09:35:13 UTC 2025
    - Last Modified: Tue Aug 26 06:24:29 UTC 2025
    - 22.9K bytes
    - Viewed (0)
Back to top