doubiaokai4998 2017-05-18 13:28
浏览 217


I'm looking for an ORM library for Golang that supports working with multiple Postgresql schemas.

The idea is to support multi-tenancy using Postgres schemas. (i.e. upon each request, check which tenant should be queried and dynamically set the schema before querying)

Is anyone familiar with such a library?

  • 写回答

1条回答 默认 最新

  • donglin5770 2017-05-18 15:07

    Please note that I've only used the standard library so far and therefore my assumption that an ORM will behave in the same manner as the database/sql package might very well be wrong.

    I believe any ORM that exposes an interface analogous to the standard one that allows you to execute plain sql statements, like xorm and gorm for example do, should be able to facilitate switching between schemas by setting the search_path.

    db.Exec("SET search_path TO tenant_schema_123")

    This sets the schema for the db handle and any successive queries using that db handle are made to tenant_schema_123.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 按键修改电子时钟,C51单片机
  • ¥60 Java中实现如何实现张量类,并用于图像处理(不运用其他科学计算库和图像处理库))
  • ¥20 5037端口被adb自己占了
  • ¥15 python:excel数据写入多个对应word文档
  • ¥60 全一数分解素因子和素数循环节位数
  • ¥15 ffmpeg如何安装到虚拟环境
  • ¥188 寻找能做王者评分提取的
  • ¥15 matlab用simulink求解一个二阶微分方程,要求截图
  • ¥30 乘子法解约束最优化问题的matlab代码文件,最好有matlab代码文件
  • ¥15 写论文,需要数据支撑