Skip to content

Commit

Permalink
feat: support for the latest mongodb v5 (#9925)
Browse files Browse the repository at this point in the history
* fix: add support for mongodb driver v5

This new fix allow support to mongodb driver v5

Closes: #7907

* refactor: remove callback from MongoDriver connect

* fix: check for propertyName in transform

* fix: add support for mongodb driver v5

This new fix allow support to mongodb driver v5

Closes: #7907

* feat: mongodb 5.2.0 typings

* fix: instanceof ObjectId check

Instanceof check now no longer references to just the
type but the loaded class ref instead.

* test: fix test name to mongodb v5

---------

Co-authored-by: Matheus Melo Antiquera <matheusantiquera@finchsolucoes.com.br>
Co-authored-by: tgrassl <grassl.timon@gmail.com>
Co-authored-by: Matheus Melo Antiquera <matheus.melo.a@hotmail.com>
  • Loading branch information
4 people committed Apr 15, 2023
1 parent 3a72e35 commit f6a3ce7
Show file tree
Hide file tree
Showing 97 changed files with 13,932 additions and 8,589 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -250,7 +250,7 @@ await timber.remove()

- for **MongoDB** (experimental)

`npm install mongodb@^3.6.0 --save`
`npm install mongodb@^5.2.0 --save`

- for **NativeScript**, **react-native** and **Cordova**

Expand Down
2 changes: 1 addition & 1 deletion README_ko.md
Expand Up @@ -184,7 +184,7 @@ await timber.remove();

- **MongoDB** (experimental)의 경우

`npm install mongodb@^3.6.0 --save`
`npm install mongodb@^5.2.0 --save`

- **NativeScript**, **react-native**, **Cordova**의 경우

Expand Down
6 changes: 3 additions & 3 deletions docs/decorator-reference.md
Expand Up @@ -287,16 +287,16 @@ Learn more about [entity columns](entities.md#entity-columns).

#### `@ObjectIdColumn`

Marks a property in your entity as ObjectID.
Marks a property in your entity as ObjectId.
This decorator is only used in MongoDB.
Every entity in MongoDB must have a ObjectID column.
Every entity in MongoDB must have a ObjectId column.
Example:

```typescript
@Entity()
export class User {
@ObjectIdColumn()
id: ObjectID
id: ObjectId
}
```

Expand Down
16 changes: 6 additions & 10 deletions docs/mongodb.md
Expand Up @@ -20,12 +20,12 @@ instead of `@PrimaryColumn` or `@PrimaryGeneratedColumn`.
Simple entity example:

```typescript
import { Entity, ObjectID, ObjectIdColumn, Column } from "typeorm"
import { Entity, ObjectId, ObjectIdColumn, Column } from "typeorm"

@Entity()
export class User {
@ObjectIdColumn()
id: ObjectID
id: ObjectId

@Column()
firstName: string
Expand Down Expand Up @@ -54,7 +54,7 @@ Since MongoDB stores objects and objects inside objects (or documents inside doc
you can do the same in TypeORM:

```typescript
import { Entity, ObjectID, ObjectIdColumn, Column } from "typeorm"
import { Entity, ObjectId, ObjectIdColumn, Column } from "typeorm"

export class Profile {
@Column()
Expand All @@ -69,7 +69,7 @@ export class Profile {
```

```typescript
import { Entity, ObjectID, ObjectIdColumn, Column } from "typeorm"
import { Entity, ObjectId, ObjectIdColumn, Column } from "typeorm"

export class Photo {
@Column()
Expand All @@ -90,12 +90,12 @@ export class Photo {
```

```typescript
import { Entity, ObjectID, ObjectIdColumn, Column } from "typeorm"
import { Entity, ObjectId, ObjectIdColumn, Column } from "typeorm"

@Entity()
export class User {
@ObjectIdColumn()
id: ObjectID
id: ObjectId

@Column()
firstName: string
Expand Down Expand Up @@ -373,10 +373,6 @@ Returns if the collection is a capped collection.

Get the list of all indexes information for the collection.

#### `mapReduce`

Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.

#### `parallelCollectionScan`

Return N number of parallel cursors for a collection allowing parallel reading of entire collection. There are no ordering guarantees for returned results
Expand Down
16 changes: 6 additions & 10 deletions docs/zh_CN/mongodb.md
Expand Up @@ -18,12 +18,12 @@ TypeORM 大多数功能都是特定于 RDBMS 的,
简单实体示例:

```typescript
import { Entity, ObjectID, ObjectIdColumn, Column } from "typeorm";
import { Entity, ObjectId, ObjectIdColumn, Column } from "typeorm";

@Entity()
export class User {
@ObjectIdColumn()
id: ObjectID;
id: ObjectId;

@Column()
firstName: string;
Expand Down Expand Up @@ -51,7 +51,7 @@ const connection: Connection = await createConnection({
由于 MongoDB 存储对象和对象内的对象(或文档内的文档),因此你可以在 TypeORM 中执行相同的操作:

```typescript
import { Entity, ObjectID, ObjectIdColumn, Column } from "typeorm";
import { Entity, ObjectId, ObjectIdColumn, Column } from "typeorm";

export class Profile {
@Column()
Expand All @@ -66,7 +66,7 @@ export class Profile {
```

```typescript
import { Entity, ObjectID, ObjectIdColumn, Column } from "typeorm";
import { Entity, ObjectId, ObjectIdColumn, Column } from "typeorm";

export class Photo {
@Column()
Expand All @@ -87,12 +87,12 @@ export class Photo {
```

```typescript
import { Entity, ObjectID, ObjectIdColumn, Column } from "typeorm";
import { Entity, ObjectId, ObjectIdColumn, Column } from "typeorm";

@Entity()
export class User {
@ObjectIdColumn()
id: ObjectID;
id: ObjectId;

@Column()
firstName: string;
Expand Down Expand Up @@ -297,10 +297,6 @@ distinct 命令返回集合中给定键的不同值列表。

获取集合的所有索引信息的列表。

#### `mapReduce`

在集合中运行 Map Reduce。 请注意,out 的内联选项将返回结果数组而不是集合。

#### `parallelCollectionScan`

为集合返回 N 个并行游标,允许并行读取整个集合。 返回的结果没有顺序保证。
Expand Down

0 comments on commit f6a3ce7

Please sign in to comment.