找不到 MongoDB TypeORM 集合中的所有项目

Not finding all items in a MongoDB TypeORM collection

当使用 findfindOne 方法从集合中获取数据时,它不会返回集合中的所有项目。

Collection.ts

@Entity()
export class Collection {

    @ObjectIdColumn()
    id !: string ;

    @Column()
    symbol !: string 

    @Column()
    name !: string

    @Column()
    description !: string

    @Column()
    image !: string

    @Column()
    totalItems !: number

    @Column()
    website!: string

    @Column ()
    categories!: string[];

    @Column()
    stats!: Stats[];

    @Column()
    isListed!: boolean;

    
}

find.ts

const collection = getMongoRepository(Collection)
await collection.findOne({ where: {  symbol : { $eq : symbol}}})

结果

Collection {
  id: 6285e19cfc929d11a2ec35fd,
  symbol: 'solpunks',
  name: 'SolPunks',
  description: 'SolPunks are one of the very first NFTs on the Solana blockchain. Each of these 10,000 SolPunks has attributes that make them unique according to a defined rarity system.',
  image: 'https://bafkreiaoifjzhau3clwdbtap7mekvdardfg25xl24kbexc7syvws35ifk4.ipfs.nftstorage.link/',
  website: '',
  categories: [ 'pfps' ],
  stats: null 
}

预期结果

Collection {
  id: 6285e19cfc929d11a2ec35fd,
  symbol: 'solpunks',
  name: 'SolPunks',
  description: 'SolPunks are one of the very first NFTs on the Solana blockchain. Each of these 10,000 SolPunks has attributes that make them unique according to a defined rarity system.',
  image: 'https://bafkreiaoifjzhau3clwdbtap7mekvdardfg25xl24kbexc7syvws35ifk4.ipfs.nftstorage.link/',
  website: '',
  categories: [ 'pfps' ],
  totalItems : 9999,
  isListed : true,
  stats: null 
}

问题

totalItemsisListed 缺失

totalItemsisListed 的命名有问题。我将其更改为蛇形后,它工作正常。

在我的例子中,我需要像文件名一样在前端命名变量。