Skip to content

Commit

Permalink
New Crowdin updates (#733)
Browse files Browse the repository at this point in the history
* New translations create.md (Japanese)

* New translations associations.md (Portuguese, Brazilian)

* New translations update.md (Chinese Simplified)

* New translations create.md (Japanese)

* New translations create.md (French)

* New translations create.md (Spanish)

* New translations create.md (Arabic)

* New translations create.md (German)

* New translations create.md (Italian)

* New translations create.md (Korean)

* New translations create.md (Polish)

* New translations create.md (Russian)

* New translations create.md (Turkish)

* New translations create.md (Chinese Simplified)

* New translations create.md (Portuguese, Brazilian)

* New translations create.md (Indonesian)

* New translations create.md (Persian)

* New translations create.md (Azerbaijani)

* New translations create.md (Hindi)
  • Loading branch information
jinzhu authored Jan 29, 2024
1 parent 5633250 commit 7245995
Show file tree
Hide file tree
Showing 18 changed files with 415 additions and 15 deletions.
25 changes: 25 additions & 0 deletions pages/ar_SA/docs/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,31 @@ type User struct {
}
```

{% note warn %}
**NOTE** **SQLite** doesn't support some records are default values when batch insert. See [SQLite Insert stmt](https://www.sqlite.org/lang_insert.html). For example:

```go
type Pet struct {
Name string `gorm:"default:cat"`
}

// In SQLite, this is not supported, so GORM will build a wrong SQL to raise error:
// INSERT INTO `pets` (`name`) VALUES ("dog"),(DEFAULT) RETURNING `name`
db.Create(&[]Pet{{Name: "dog"}, {}})
```
A viable alternative is to assign default value to fields in the hook, e.g.

```go
func (p *Pet) BeforeCreate(tx *gorm.DB) (err error) {
if p.Name == "" {
p.Name = "cat"
}
}
```

You can see more info in [issues#6335](https://github.com/go-gorm/gorm/issues/6335)
{% endnote %}

When using virtual/generated value, you might need to disable its creating/updating permission, check out [Field-Level Permission](models.html#field_permission)

### <span id="upsert">Upsert / On Conflict</span>
Expand Down
25 changes: 25 additions & 0 deletions pages/az_AZ/docs/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,31 @@ type User struct {
}
```

{% note warn %}
**NOTE** **SQLite** doesn't support some records are default values when batch insert. See [SQLite Insert stmt](https://www.sqlite.org/lang_insert.html). For example:

```go
type Pet struct {
Name string `gorm:"default:cat"`
}

// In SQLite, this is not supported, so GORM will build a wrong SQL to raise error:
// INSERT INTO `pets` (`name`) VALUES ("dog"),(DEFAULT) RETURNING `name`
db.Create(&[]Pet{{Name: "dog"}, {}})
```
A viable alternative is to assign default value to fields in the hook, e.g.

```go
func (p *Pet) BeforeCreate(tx *gorm.DB) (err error) {
if p.Name == "" {
p.Name = "cat"
}
}
```

You can see more info in [issues#6335](https://github.com/go-gorm/gorm/issues/6335)
{% endnote %}

When using virtual/generated value, you might need to disable its creating/updating permission, check out [Field-Level Permission](models.html#field_permission)

### <span id="upsert">Upsert / On Conflict</span>
Expand Down
25 changes: 25 additions & 0 deletions pages/de_DE/docs/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,31 @@ type User struct {
}
```

{% note warn %}
**NOTE** **SQLite** doesn't support some records are default values when batch insert. See [SQLite Insert stmt](https://www.sqlite.org/lang_insert.html). For example:

```go
type Pet struct {
Name string `gorm:"default:cat"`
}

// In SQLite, this is not supported, so GORM will build a wrong SQL to raise error:
// INSERT INTO `pets` (`name`) VALUES ("dog"),(DEFAULT) RETURNING `name`
db.Create(&[]Pet{{Name: "dog"}, {}})
```
A viable alternative is to assign default value to fields in the hook, e.g.

```go
func (p *Pet) BeforeCreate(tx *gorm.DB) (err error) {
if p.Name == "" {
p.Name = "cat"
}
}
```

You can see more info in [issues#6335](https://github.com/go-gorm/gorm/issues/6335)
{% endnote %}

When using virtual/generated value, you might need to disable its creating/updating permission, check out [Field-Level Permission](models.html#field_permission)

### <span id="upsert">Upsert / On Conflict</span>
Expand Down
25 changes: 25 additions & 0 deletions pages/es_ES/docs/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,31 @@ type User struct {
}
```

{% note warn %}
**NOTE** **SQLite** doesn't support some records are default values when batch insert. See [SQLite Insert stmt](https://www.sqlite.org/lang_insert.html). For example:

```go
type Pet struct {
Name string `gorm:"default:cat"`
}

// In SQLite, this is not supported, so GORM will build a wrong SQL to raise error:
// INSERT INTO `pets` (`name`) VALUES ("dog"),(DEFAULT) RETURNING `name`
db.Create(&[]Pet{{Name: "dog"}, {}})
```
A viable alternative is to assign default value to fields in the hook, e.g.

```go
func (p *Pet) BeforeCreate(tx *gorm.DB) (err error) {
if p.Name == "" {
p.Name = "cat"
}
}
```

You can see more info in [issues#6335](https://github.com/go-gorm/gorm/issues/6335)
{% endnote %}

When using virtual/generated value, you might need to disable its creating/updating permission, check out [Field-Level Permission](models.html#field_permission)

### <span id="upsert">Upsert / On Conflict</span>
Expand Down
25 changes: 25 additions & 0 deletions pages/fa_IR/docs/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,31 @@ type User struct {
}
```

{% note warn %}
**NOTE** **SQLite** doesn't support some records are default values when batch insert. See [SQLite Insert stmt](https://www.sqlite.org/lang_insert.html). For example:

```go
type Pet struct {
Name string `gorm:"default:cat"`
}

// In SQLite, this is not supported, so GORM will build a wrong SQL to raise error:
// INSERT INTO `pets` (`name`) VALUES ("dog"),(DEFAULT) RETURNING `name`
db.Create(&[]Pet{{Name: "dog"}, {}})
```
A viable alternative is to assign default value to fields in the hook, e.g.

```go
func (p *Pet) BeforeCreate(tx *gorm.DB) (err error) {
if p.Name == "" {
p.Name = "cat"
}
}
```

You can see more info in [issues#6335](https://github.com/go-gorm/gorm/issues/6335)
{% endnote %}

When using virtual/generated value, you might need to disable its creating/updating permission, check out [Field-Level Permission](models.html#field_permission)

### <span id="upsert">Upsert / On Conflict</span>
Expand Down
25 changes: 25 additions & 0 deletions pages/fr_FR/docs/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,31 @@ type User struct {
}
```

{% note warn %}
**NOTE** **SQLite** doesn't support some records are default values when batch insert. See [SQLite Insert stmt](https://www.sqlite.org/lang_insert.html). For example:

```go
type Pet struct {
Name string `gorm:"default:cat"`
}

// In SQLite, this is not supported, so GORM will build a wrong SQL to raise error:
// INSERT INTO `pets` (`name`) VALUES ("dog"),(DEFAULT) RETURNING `name`
db.Create(&[]Pet{{Name: "dog"}, {}})
```
A viable alternative is to assign default value to fields in the hook, e.g.

```go
func (p *Pet) BeforeCreate(tx *gorm.DB) (err error) {
if p.Name == "" {
p.Name = "cat"
}
}
```

You can see more info in [issues#6335](https://github.com/go-gorm/gorm/issues/6335)
{% endnote %}

When using virtual/generated value, you might need to disable its creating/updating permission, check out [Field-Level Permission](models.html#field_permission)

### <span id="upsert">Upsert / On Conflict</span>
Expand Down
25 changes: 25 additions & 0 deletions pages/hi_IN/docs/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,31 @@ type User struct {
}
```

{% note warn %}
**NOTE** **SQLite** doesn't support some records are default values when batch insert. See [SQLite Insert stmt](https://www.sqlite.org/lang_insert.html). For example:

```go
type Pet struct {
Name string `gorm:"default:cat"`
}

// In SQLite, this is not supported, so GORM will build a wrong SQL to raise error:
// INSERT INTO `pets` (`name`) VALUES ("dog"),(DEFAULT) RETURNING `name`
db.Create(&[]Pet{{Name: "dog"}, {}})
```
A viable alternative is to assign default value to fields in the hook, e.g.

```go
func (p *Pet) BeforeCreate(tx *gorm.DB) (err error) {
if p.Name == "" {
p.Name = "cat"
}
}
```

You can see more info in [issues#6335](https://github.com/go-gorm/gorm/issues/6335)
{% endnote %}

When using virtual/generated value, you might need to disable its creating/updating permission, check out [Field-Level Permission](models.html#field_permission)

### <span id="upsert">Upsert / On Conflict</span>
Expand Down
25 changes: 25 additions & 0 deletions pages/id_ID/docs/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,31 @@ type User struct {
}
```

{% note warn %}
**NOTE** **SQLite** doesn't support some records are default values when batch insert. See [SQLite Insert stmt](https://www.sqlite.org/lang_insert.html). For example:

```go
type Pet struct {
Name string `gorm:"default:cat"`
}

// In SQLite, this is not supported, so GORM will build a wrong SQL to raise error:
// INSERT INTO `pets` (`name`) VALUES ("dog"),(DEFAULT) RETURNING `name`
db.Create(&[]Pet{{Name: "dog"}, {}})
```
A viable alternative is to assign default value to fields in the hook, e.g.

```go
func (p *Pet) BeforeCreate(tx *gorm.DB) (err error) {
if p.Name == "" {
p.Name = "cat"
}
}
```

You can see more info in [issues#6335](https://github.com/go-gorm/gorm/issues/6335)
{% endnote %}

When using virtual/generated value, you might need to disable its creating/updating permission, check out [Field-Level Permission](models.html#field_permission)

### <span id="upsert">Upsert / On Conflict</span>
Expand Down
25 changes: 25 additions & 0 deletions pages/it_IT/docs/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,31 @@ type User struct {
}
```

{% note warn %}
**NOTE** **SQLite** doesn't support some records are default values when batch insert. See [SQLite Insert stmt](https://www.sqlite.org/lang_insert.html). For example:

```go
type Pet struct {
Name string `gorm:"default:cat"`
}

// In SQLite, this is not supported, so GORM will build a wrong SQL to raise error:
// INSERT INTO `pets` (`name`) VALUES ("dog"),(DEFAULT) RETURNING `name`
db.Create(&[]Pet{{Name: "dog"}, {}})
```
A viable alternative is to assign default value to fields in the hook, e.g.

```go
func (p *Pet) BeforeCreate(tx *gorm.DB) (err error) {
if p.Name == "" {
p.Name = "cat"
}
}
```

You can see more info in [issues#6335](https://github.com/go-gorm/gorm/issues/6335)
{% endnote %}

When using virtual/generated value, you might need to disable its creating/updating permission, check out [Field-Level Permission](models.html#field_permission)

### <span id="upsert">Upsert / On Conflict</span>
Expand Down
39 changes: 32 additions & 7 deletions pages/ja_JP/docs/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ result.RowsAffected // returns inserted records count
```

{% note warn %}
**NOTE** You cannot pass a struct to 'create', so you should pass a pointer to the data.
**注意** **Create()**の引数として構造体を渡すことはできません。代わりにポインタを渡すようにしてください。
{% endnote %}

## フィールドを選択してレコードを作成する

Create a record and assign a value to the fields specified.
レコード作成時に、Selectで指定されたフィールドのみに対して値をアサインできます。

```go
db.Select("Name", "Age", "CreatedAt").Create(&user)
// INSERT INTO `users` (`name`,`age`,`created_at`) VALUES ("jinzhu", 18, "2020-07-04 11:05:21.775")
```

Create a record and ignore the values for fields passed to omit.
省略する項目を指定し、レコードを作成します。

```go
db.Omit("Name", "Age", "CreatedAt").Create(&user)
Expand All @@ -50,7 +50,7 @@ db.Omit("Name", "Age", "CreatedAt").Create(&user)

## <span id="batch_insert">一括作成</span>

To efficiently insert large number of records, pass a slice to the `Create` method. GORM will generate a single SQL statement to insert all the data and backfill primary key values, hook methods will be invoked too. It will begin a **transaction** when records can be split into multiple batches.
大量のレコードを効率的に挿入するには、スライスを `Create` メソッドに渡します。 GORMはすべてのデータを挿入する1つのSQL文を生成します。SQLが実行されると登録された主キーの値がモデルに代入され、フックメソッドも呼び出されます。 レコードを複数のバッチに分割することが可能な場合には、 **トランザクション** が開始されます。

```go
var users = []User{{Name: "jinzhu1"}, {Name: "jinzhu2"}, {Name: "jinzhu3"}}
Expand All @@ -61,7 +61,7 @@ for _, user := range users {
}
```

You can specify batch size when creating with `CreateInBatches`, e.g:
`CreateInBatches` を利用することで、バッチサイズを指定してレコードを作成することができます。

```go
var users = []User{{Name: "jinzhu_1"}, ...., {Name: "jinzhu_10000"}}
Expand All @@ -70,10 +70,10 @@ var users = []User{{Name: "jinzhu_1"}, ...., {Name: "jinzhu_10000"}}
db.CreateInBatches(users, 100)
```

Batch Insert is also supported when using [Upsert](#upsert) and [Create With Associations](#create_with_associations)
[Upsert](#upsert) [Create With Associations](#create_with_associations) を使用する場合もバッチインサートはサポートされています。

{% note warn %}
**NOTE** initialize GORM with `CreateBatchSize` option, all `INSERT` will respect this option when creating record & associations
**注記** `CreateBatchSize` オプションを使ってGORMを初期化した場合、すべての `INSERT` は、その設定を参照してレコードやアソシエーションを作成します。
{% endnote %}

```go
Expand Down Expand Up @@ -257,6 +257,31 @@ type User struct {
}
```

{% note warn %}
**NOTE** **SQLite** doesn't support some records are default values when batch insert. See [SQLite Insert stmt](https://www.sqlite.org/lang_insert.html). For example:

```go
type Pet struct {
Name string `gorm:"default:cat"`
}

// In SQLite, this is not supported, so GORM will build a wrong SQL to raise error:
// INSERT INTO `pets` (`name`) VALUES ("dog"),(DEFAULT) RETURNING `name`
db.Create(&[]Pet{{Name: "dog"}, {}})
```
A viable alternative is to assign default value to fields in the hook, e.g.

```go
func (p *Pet) BeforeCreate(tx *gorm.DB) (err error) {
if p.Name == "" {
p.Name = "cat"
}
}
```

You can see more info in [issues#6335](https://github.com/go-gorm/gorm/issues/6335)
{% endnote %}

When using virtual/generated value, you might need to disable its creating/updating permission, check out [Field-Level Permission](models.html#field_permission)

### <span id="upsert">コンフリクト発生時のUpsert</span>
Expand Down
Loading

0 comments on commit 7245995

Please sign in to comment.