【问题标题】:how to add autoincrement column in mongodb with typeorm如何使用 typeorm 在 mongodb 中添加自动增量列
【发布时间】:2021-06-20 07:43:36
【问题描述】:

我正在使用 nestjs 并尝试通过 typeorm 和 mongodb 驱动程序添加一个自动增量列,但没有发生任何事情,也没有创建该列 这就是我的命令

import { Column, Entity, Generated, ObjectIdColumn } from "typeorm";

@Entity({name : 'employees'})
export class Employees {
    @ObjectIdColumn()
    id : string  
    
    @Column({type : 'string'})
    userName : string 
    
    @Column({type : 'string'})
    fullName : string 

    @Column()
    @Generated('increment')
    employeeID : string

该功能在 mongodb 中可用还是仅在 mysql 中可用

【问题讨论】:

    标签: mongodb nestjs typeorm


    【解决方案1】:

    MongoDB 不支持自增。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-31
    • 2020-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多