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

Store embeddables as embedded documents when using mongoDB #906

Closed
jeanbmar opened this issue Oct 7, 2020 · 1 comment · Fixed by #927
Closed

Store embeddables as embedded documents when using mongoDB #906

jeanbmar opened this issue Oct 7, 2020 · 1 comment · Fixed by #927
Assignees
Labels
enhancement New feature or request

Comments

@jeanbmar
Copy link

jeanbmar commented Oct 7, 2020

Is your feature request related to a problem? Please describe.
At the moment, embeddables are stored in mongoDB like a RDBMS. While this is not an issue when manipulating data in memory, it becomes unnatural and limiting when working aside with the database.

Describe the solution you'd like
Before :

{
    "_id": ObjectId("5f7de71931bfe0652853c1e6"),
    "address_street": "foo",
    "address_country": "bar"
}

After :

{
    "_id": ObjectId("5f7de71931bfe0652853c1e6"),
    "address": { 
        "street": "foo",
        "country": "bar"
    }
}
@jeanbmar jeanbmar added the enhancement New feature or request label Oct 7, 2020
@B4nan
Copy link
Member

B4nan commented Oct 7, 2020

Yeah agreed, I wanted to allow this optionally from the very beginning, as it could work the same in SQL drivers too via JSON columns. I would still keep the current behaviour as default probably, as otherwise it could be seen as breaking change.

@jeanbmar jeanbmar changed the title Store embeddables as embedded documents when using mongDB Store embeddables as embedded documents when using mongoDB Oct 7, 2020
@B4nan B4nan self-assigned this Oct 18, 2020
B4nan added a commit that referenced this issue Oct 18, 2020
```ts
@entity()
export class User {

  @Embedded({ entity: () => Address, object: true })
  address!: Address;

}
```

In SQL drivers, this will use a JSON column to store the value.

> Only MySQL and PostgreSQL drivers support searching by JSON properties currently.

Related: #906
B4nan added a commit that referenced this issue Oct 18, 2020
```ts
@entity()
export class User {

  @Embedded({ entity: () => Address, object: true })
  address!: Address;

}
```

In SQL drivers, this will use a JSON column to store the value.

> Only MySQL and PostgreSQL drivers support searching by JSON properties currently.

Closes #906
B4nan added a commit that referenced this issue Oct 18, 2020
```ts
@entity()
export class User {

  @Embedded({ entity: () => Address, object: true })
  address!: Address;

}
```

In SQL drivers, this will use a JSON column to store the value.

> Only MySQL and PostgreSQL drivers support searching by JSON properties currently.

Closes #906
B4nan added a commit that referenced this issue Oct 18, 2020
```ts
@entity()
export class User {

  @Embedded({ entity: () => Address, object: true })
  address!: Address;

}
```

In SQL drivers, this will use a JSON column to store the value.

> Only MySQL and PostgreSQL drivers support searching by JSON properties currently.

Closes #906
B4nan added a commit that referenced this issue Oct 18, 2020
```ts
@entity()
export class User {

  @Embedded({ entity: () => Address, object: true })
  address!: Address;

}
```

In SQL drivers, this will use a JSON column to store the value.

> Only MySQL and PostgreSQL drivers support searching by JSON properties currently.

Closes #906
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants