Navigation

    MemFireDB论坛

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    多表关联支持吗?

    MemFireDB用户问答
    2
    2
    8
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • X
      xiaona last edited by

      使用的MemFire Cloud,多表关联支持吗,多表关联计算,使用多个sql语句能否自动生成接口?

      A 1 Reply Last reply Reply Quote 0
      • A
        admin @xiaona last edited by admin

        @xiaona @xiaona MemFire Cloud支持多表关联,
        使用python进行多表关联查询,可以参考:https://community.memfiredb.com/topic/311/使用python接口来进行关联查询操作
        使用JS进行多表关联查询,可以参考:
        https://supabase.com/docs/reference/javascript/select
        例如:Query foreign tables
        建表:

        
        create table
          countries (id int8 primary key, name text);
        create table
          cities (
            id int8 primary key,
            country_id int8 not null references countries,
            name text
          );
        

        查询

        const { data, error } = await supabase
          .from('countries')
          .select(`
            name,
            cities (
              name
            )
          `)
        
        

        返回结果

        {
          "data": [
            {
              "name": "Germany",
              "cities": [
                {
                  "name": "Munich"
                }
              ]
            },
            {
              "name": "Indonesia",
              "cities": [
                {
                  "name": "Bali"
                }
              ]
            }
          ],
          "status": 200,
          "statusText": "OK"
        }
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post