简体   繁体   中英

How to set the mongodb collection name when using loopback v4?

Loopback v.4相对较新,我在stackoverflow上找不到如何修改mongodb集合的名称。

after sometime (try and error), found out that the collection name is exactly your model name.

the structure of the loopback 4 as far as i know:

  • models
    • yourmodel.model.ts
  • datasources
    • yourdatasource.datasource.ts
    • yourdatasource.datasource.json
  • controllers
  • repositories

i think it would be nice if they add the collection name as a field to the json file in datasource directory, since it already includes the configuration for the mongodb.

hope this helps. thought it would be nice to have this on Stackoverflow. Please feel free to add to this answer, so it would cover more edge cases.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM