Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 6 of 6 for limit (0.2 sec)

  1. chainable_api.go

    				}},
    			})
    		}
    	}
    	return
    }
    
    // Limit specify the number of records to be retrieved
    //
    // Limit conditions can be cancelled by using `Limit(-1)`.
    //
    //	// retrieve 3 users
    //	db.Limit(3).Find(&users)
    //	// retrieve 3 users into users1, and all users into users2
    //	db.Limit(3).Find(&users1).Limit(-1).Find(&users2)
    func (db *DB) Limit(limit int) (tx *DB) {
    	tx = db.getInstance()
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Wed Apr 17 03:38:55 GMT 2024
    - 14.3K bytes
    - Viewed (1)
  2. finisher_api.go

    		queryDB      = tx
    		rowsAffected int64
    		batch        int
    	)
    
    	// user specified offset or limit
    	var totalSize int
    	if c, ok := tx.Statement.Clauses["LIMIT"]; ok {
    		if limit, ok := c.Expression.(clause.Limit); ok {
    			if limit.Limit != nil {
    				totalSize = *limit.Limit
    			}
    
    			if totalSize > 0 && batchSize > totalSize {
    				batchSize = totalSize
    			}
    
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 22.7K bytes
    - Viewed (0)
  3. migrator/migrator.go

    	columnTypes := make([]gorm.ColumnType, 0)
    	execErr := m.RunWithValue(value, func(stmt *gorm.Statement) (err error) {
    		rows, err := m.DB.Session(&gorm.Session{}).Table(stmt.Table).Limit(1).Rows()
    		if err != nil {
    			return err
    		}
    
    		defer func() {
    			err = rows.Close()
    		}()
    
    		var rawColumnTypes []*sql.ColumnType
    		rawColumnTypes, err = rows.ColumnTypes()
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Apr 26 07:15:49 GMT 2024
    - 29K bytes
    - Viewed (0)
  4. tests/transaction_test.go

    	user := GetUser("tTestTransactionWithHooks", Config{Account: true})
    	DB.Create(&user)
    
    	var err error
    	err = DB.Transaction(func(tx *gorm.DB) error {
    		return tx.Model(&User{}).Limit(1).Transaction(func(tx2 *gorm.DB) error {
    			return tx2.Scan(&User{}).Error
    		})
    	})
    
    	if err != nil {
    		t.Error(err)
    	}
    
    	// method with hooks
    	err = DB.Transaction(func(tx1 *gorm.DB) error {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sat Jun 10 13:05:19 GMT 2023
    - 10.9K bytes
    - Viewed (0)
  5. tests/sql_builder_test.go

    	// find
    	sql := DB.ToSQL(func(tx *gorm.DB) *gorm.DB {
    		return tx.Model(&User{}).Where("id = ?", 100).Limit(10).Order("age desc").Find(&[]User{})
    	})
    	assertEqualSQL(t, `SELECT * FROM "users" WHERE id = 100 AND "users"."deleted_at" IS NULL ORDER BY age desc LIMIT 10`, sql)
    
    	// after model changed
    	if DB.Statement.DryRun || DB.DryRun {
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Fri Jan 12 08:42:21 GMT 2024
    - 16.7K bytes
    - Viewed (0)
  6. gorm.go

    	}
    	db.Plugins[name] = plugin
    	return nil
    }
    
    // ToSQL for generate SQL string.
    //
    //	db.ToSQL(func(tx *gorm.DB) *gorm.DB {
    //			return tx.Model(&User{}).Where(&User{Name: "foo", Age: 20})
    //				.Limit(10).Offset(5)
    //				.Order("name ASC")
    //				.First(&User{})
    //	})
    func (db *DB) ToSQL(queryFn func(tx *DB) *DB) string {
    	tx := queryFn(db.Session(&Session{DryRun: true, SkipDefaultTransaction: true}))
    Go
    - Registered: Sun May 05 09:35:13 GMT 2024
    - Last Modified: Sun Aug 20 11:46:56 GMT 2023
    - 11.6K bytes
    - Viewed (0)
Back to top