Get

Get( ref, [ts] )
Get( ref, [ts] )
Get( ref, [ts] )
Get( ref, [ts] )
get( ref, [ts] )
get ref [ts]
Get( ref, [ts] )
Get( ref, [ts] )

Description

The Get function retrieves a single instance identified by ref. An optional timestamp (ts) can be provided to retrieve the instance which existed at the specific date and time. If the timestamp is omitted the default is the current time.

Errors

  • If the instance does not exist, an "instance not found" error is returned. Use the exists predicate to avoid "instance not found" errors.

  • If the client does not have read permission for the instance, a "permission denied" error is returned.

Parameter

Argument Type Definition and Requirements

ref

Reference

An instance reference uniquely identifies an instance

ts

Integer or time value

Optional - Return the instance at the specified point in time (number of UNIX microseconds or Timestamp). The default is the current time.

Returns

An instance object containing both the instance data and metadata described below.

Field Name Field Type Definition and Requirements

ref

Reference

The reference identifies the instance retrieved.

data

Object

The instance data retrieved at the location pointed to by ref.

ts

Long

The timestamp associated with the creation of the instance.

Examples

The query below retrieves an instance by providing a reference to the Class "spells" at a specific id.

curl https://db.fauna.com/ \
    -u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
    -d '{ "get": { "@ref": "classes/spells/181388642046968320" } }'
client.Query(Get(Ref("classes/spells/181388642046968320")));
System.out.println(
      client.query(
              Get(Ref(
                      Class("spells"),
                      Value(181388642046968320L)
                      )
              )
      ).get());
result, _ := client.Query(f.Get(f.RefClass(f.Class("spells"), "181388642046968320")))

fmt.Println(result)
client.query(Get(Ref("classes/spells/181388642046968320")))
client.query(q.get(Ref("classes/spells/181388642046968320")))
$client.query do
  get ref('classes/spells/181388642046968320')
end
client.query(Get(Ref("classes/spells/181388642046968320")))
client.query(q.Get(q.Ref(q.Class("spells"), 181388642046968320)))
  .then((ret) => console.log(ret));
HTTP/1.1 200 OK
{
  "resource": {
    "ref": { "@ref": "classes/spells/181388642046968320" },
    "class": { "@ref": "classes/spells" },
    "ts": 1509244539547758,
    "data": {
      "name": "Fire Beak",
      "element": [ "air", "fire" ],
      "spellbook": { "@ref": "classes/spellbooks/181388642139243008" }
    }
  }
}
{
  "ref": { "@ref": "classes/spells/181388642046968320" },
  "class": { "@ref": "classes/spells" },
  "ts": 1509244539547758,
  "data": {
    "name": "Fire Beak",
    "element": [ "air", "fire" ],
    "spellbook": { "@ref": "classes/spellbooks/181388642139243008" }
  }
}
{
  ref: ref(id = "181388642046968320", class = ref(id = "spells", class = ref(id = "classes"))),
  ts: 1536604020492774,
  data: {
    name: "Fire Beak",
    element: ["air", "fire"],
    spellbooks: ref(id = "181388642139243008", class = ref(id = "spellbooks", class = ref(id = "classes")))
  }
}
map[ref:{181388642046968320 0xc4201c7440 <nil>} ts:1509244539547758 data:map[element:[air fire] name:Fire Beak spellbook:{181388642139243008 0xc4201c77c0 <nil>}]]
{
  "ref": { "@ref": "classes/spells/181388642046968320" },
  "class": { "@ref": "classes/spells" },
  "ts": 1509244539547758,
  "data": {
    "name": "Fire Beak",
    "element": [ "air", "fire" ],
    "spellbook": { "@ref": "classes/spellbooks/181388642139243008" }
  }
}
{
  "ref": { "@ref": "classes/spells/181388642046968320" },
  "class": { "@ref": "classes/spells" },
  "ts": 1509244539547758,
  "data": {
    "name": "Fire Beak",
    "element": [ "air", "fire" ],
    "spellbook": { "@ref": "classes/spellbooks/181388642139243008" }
  }
}
{
  "ref": { "@ref": "classes/spells/181388642046968320" },
  "class": { "@ref": "classes/spells" },
  "ts": 1509244539547758,
  "data": {
    "name": "Fire Beak",
    "element": [ "air", "fire" ],
    "spellbook": { "@ref": "classes/spellbooks/181388642139243008" }
  }
}
{
  "ref": { "@ref": "classes/spells/181388642046968320" },
  "class": { "@ref": "classes/spells" },
  "ts": 1509244539547758,
  "data": {
    "name": "Fire Beak",
    "element": [ "air", "fire" ],
    "spellbook": { "@ref": "classes/spellbooks/181388642139243008" }
  }
}
{ ref: Ref(id=181388642046968320, class=Ref(id=spells, class=Ref(id=classes))),
  ts: 1526677786695156,
  data:
   { name: "Fire Beak",
     element: [ "air", "fire" ],
     spellbook: Ref(id=181388642139243008, class=Ref(id=spellbooks, class=Ref(id=classes))) } }

To retrieve multiple references in a single operation, utilize the array operator to group and return multiple instance records. The example below returns three different identifiers from the spells class in a single database operation. This saves network bandwidth and processing by grouping several requests for data into the same operation.

curl https://db.fauna.com/ \
    -u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
    -d '[
          { "get": { "@ref": "classes/spells/181388642046968320" } },
          { "get": { "@ref": "classes/spells/181388642071085568" } },
          { "get": { "@ref": "classes/spells/181388642088911360" } }
        ]'
client.Query(
  Arr(
    Get(Ref("classes/spells/181388642046968320")),
    Get(Ref("classes/spells/181388642071085568")),
    Get(Ref("classes/spells/181388642088911360"))
  ));
System.out.println(
      client.query(
          Arr(
              Get(Ref(Class("spells"),Value(181388642046968320L))),
              Get(Ref(Class("spells"),Value(181388642071085568L))),
              Get(Ref(Class("spells"),Value(181388642088911360L)))
          )
      ).get());
result, _ := client.Query(
    f.Arr{
        f.Get(f.RefClass(f.Class("spells"), "181388642046968320")),
        f.Get(f.RefClass(f.Class("spells"), "181388642071085568")),
        f.Get(f.RefClass(f.Class("spells"), "181388642088911360")),
    },
)

fmt.Println(result)
client.query(
  Arr(
    Get(Ref("classes/spells/181388642046968320")),
    Get(Ref("classes/spells/181388642071085568")),
    Get(Ref("classes/spells/181388642088911360"))
  ))
client.query(
  [
    q.get(Ref("classes/spells/181388642046968320")),
    q.get(Ref("classes/spells/181388642071085568")),
    q.get(Ref("classes/spells/181388642088911360"))
  ])
$client.query do
  [
    get(ref('classes/spells/181388642046968320')),
    get(ref('classes/spells/181388642071085568')),
    get(ref('classes/spells/181388642088911360'))
  ]
end
client.query(
    Arr(
        Get(Ref("classes/spells/181388642046968320")),
        Get(Ref("classes/spells/181388642071085568")),
        Get(Ref("classes/spells/181388642088911360"))
    )
)
client.query([
  q.Get(q.Ref(q.Class("spells"), 181388642046968320)),
  q.Get(q.Ref(q.Class("spells"), 181388642071085568)),
  q.Get(q.Ref(q.Class("spells"), 181388642088911360))
]).then((ret) => console.log(ret));
HTTP/1.1 200 OK
{
  "resource": [
    {
      "ref": { "@ref": "classes/spells/181388642046968320" },
      "class": { "@ref": "classes/spells" },
      "ts": 1509244539547758,
      "data": {
        "name": "Fire Beak",
        "element": [ "air", "fire" ],
        "spellbook": { "@ref": "classes/spellbooks/181388642139243008" }
      }
    },
    {
      "ref": { "@ref": "classes/spells/181388642071085568" },
      "class": { "@ref": "classes/spells" },
      "ts": 1509244539547758,
      "data": {
        "name": "Water Dragon's Claw",
        "element": [ "water", "fire" ],
        "spellbook": { "@ref": "classes/spellbooks/181388642139243008" }
      }
    },
    {
      "ref": { "@ref": "classes/spells/181388642088911360" },
      "class": { "@ref": "classes/spells" },
      "ts": 1509244539235128,
      "data": {
        "name": "Hippo's Wallow",
        "element": [ "water", "earth" ]
      }
    }
  ]
}
[
  {
    "ref": { "@ref": "classes/spells/181388642046968320" },
    "class": { "@ref": "classes/spells" },
    "ts": 1509244539547758,
    "data": {
      "name": "Fire Beak",
      "element": [ "air", "fire" ],
      "spellbook": { "@ref": "classes/spellbooks/181388642139243008" }
    }
  },
  {
    "ref": { "@ref": "classes/spells/181388642071085568" },
    "class": { "@ref": "classes/spells" },
    "ts": 1509244539547758,
    "data": {
      "name": "Water Dragon's Claw",
      "element": [ "water", "fire" ],
      "spellbook": { "@ref": "classes/spellbooks/181388642139243008" }
    }
  },
  {
    "ref": { "@ref": "classes/spells/181388642088911360" },
    "class": { "@ref": "classes/spells" },
    "ts": 1509244539235128,
    "data": {
      "name": "Hippo's Wallow",
      "element": [ "water", "earth" ]
    }
  }
]
[
   {
     ref: ref(id = "181388642046968320", class = ref(id = "spells", class = ref(id = "classes"))),
     ts: 1536604020492774,
     data: {
       name: "Fire Beak",
       element: ["air", "fire"],
       spellbooks: ref(id = "181388642139243008", class = ref(id = "spellbooks", class = ref(id = "classes")))
     }
   },
   {
     ref: ref(id = "181388642071085568", class = ref(id = "spells", class = ref(id = "classes"))),
     ts: 1536604020513444,
     data: {
       name: "Water Dragon's Claw",
       element: ["water", "fire"],
       spellbooks: ref(id = "181388642139243008", class = ref(id = "spellbooks", class = ref(id = "classes")))
     }
   },
   {
     ref: ref(id = "181388642088911360", class = ref(id = "spells", class = ref(id = "classes"))),
     ts: 1536604020270318,
     data: {
       name: "Hippo's Wallow",
       element: ["water", "earth"]
     }
   }
 ]
[
  map[ref:{181388642046968320 0xc4201d6f20 <nil>} ts:1509244539547758 data:map[element:[air fire] name:Fire Beak spellbook:{181388642139243008 0xc4201d72a0 <nil>}]]
  map[ref:{181388642071085568 0xc4201d74e0 <nil>} ts:1509244539547758 data:map[element:[water fire] name:Water Dragon's Claw spellbook:{181388642139243008 0xc4201d7860 <nil>}]]
  map[ref:{181388642088911360 0xc4201d7ac0 <nil>} ts:1509244539235128 data:map[element:[water earth] name:Hippo's Wallow]]
]
[
  {
    "ref": { "@ref": "classes/spells/181388642046968320" },
    "class": { "@ref": "classes/spells" },
    "ts": 1509244539547758,
    "data": {
      "name": "Fire Beak",
      "element": [ "air", "fire" ],
      "spellbook": { "@ref": "classes/spellbooks/181388642139243008" }
    }
  },
  {
    "ref": { "@ref": "classes/spells/181388642071085568" },
    "class": { "@ref": "classes/spells" },
    "ts": 1509244539547758,
    "data": {
      "name": "Water Dragon's Claw",
      "element": [ "water", "fire" ],
      "spellbook": { "@ref": "classes/spellbooks/181388642139243008" }
    }
  },
  {
    "ref": { "@ref": "classes/spells/181388642088911360" },
    "class": { "@ref": "classes/spells" },
    "ts": 1509244539235128,
    "data": {
      "name": "Hippo's Wallow",
      "element": [ "water", "earth" ]
    }
  }
]
[
  {
    "ref": { "@ref": "classes/spells/181388642046968320" },
    "class": { "@ref": "classes/spells" },
    "ts": 1509244539547758,
    "data": {
      "name": "Fire Beak",
      "element": [ "air", "fire" ],
      "spellbook": { "@ref": "classes/spellbooks/181388642139243008" }
    }
  },
  {
    "ref": { "@ref": "classes/spells/181388642071085568" },
    "class": { "@ref": "classes/spells" },
    "ts": 1509244539547758,
    "data": {
      "name": "Water Dragon's Claw",
      "element": [ "water", "fire" ],
      "spellbook": { "@ref": "classes/spellbooks/181388642139243008" }
    }
  },
  {
    "ref": { "@ref": "classes/spells/181388642088911360" },
    "class": { "@ref": "classes/spells" },
    "ts": 1509244539235128,
    "data": {
      "name": "Hippo's Wallow",
      "element": [ "water", "earth" ]
    }
  }
]
[
  {
    "ref": { "@ref": "classes/spells/181388642046968320" },
    "class": { "@ref": "classes/spells" },
    "ts": 1509244539547758,
    "data": {
      "name": "Fire Beak",
      "element": [ "air", "fire" ],
      "spellbook": { "@ref": "classes/spellbooks/181388642139243008" }
    }
  },
  {
    "ref": { "@ref": "classes/spells/181388642071085568" },
    "class": { "@ref": "classes/spells" },
    "ts": 1509244539547758,
    "data": {
      "name": "Water Dragon's Claw",
      "element": [ "water", "fire" ],
      "spellbook": { "@ref": "classes/spellbooks/181388642139243008" }
    }
  },
  {
    "ref": { "@ref": "classes/spells/181388642088911360" },
    "class": { "@ref": "classes/spells" },
    "ts": 1509244539235128,
    "data": {
      "name": "Hippo's Wallow",
      "element": [ "water", "earth" ]
    }
  }
]
[
  {
    "ref": { "@ref": "classes/spells/181388642046968320" },
    "class": { "@ref": "classes/spells" },
    "ts": 1509244539547758,
    "data": {
      "name": "Fire Beak",
      "element": [ "air", "fire" ],
      "spellbook": { "@ref": "classes/spellbooks/181388642139243008" }
    }
  },
  {
    "ref": { "@ref": "classes/spells/181388642071085568" },
    "class": { "@ref": "classes/spells" },
    "ts": 1509244539547758,
    "data": {
      "name": "Water Dragon's Claw",
      "element": [ "water", "fire" ],
      "spellbook": { "@ref": "classes/spellbooks/181388642139243008" }
    }
  },
  {
    "ref": { "@ref": "classes/spells/181388642088911360" },
    "class": { "@ref": "classes/spells" },
    "ts": 1509244539235128,
    "data": {
      "name": "Hippo's Wallow",
      "element": [ "water", "earth" ]
    }
  }
]
[ { ref: Ref(id=181388642046968320, class=Ref(id=spells, class=Ref(id=classes))),
    ts: 1509244539547758,
    data:
     { name: "Fire Beak",
       element: [ "air", "fire" ],
       spellbook: Ref(id=181388642139243008, class=Ref(id=spellbooks, class=Ref(id=classes))) } },
  { ref: Ref(id=181388642071085568, class=Ref(id=spells, class=Ref(id=classes))),
    ts: 1509244539547758,
    data:
     { name: "Water Dragon's Claw",
       element: [ "water", "fire" ],
       spellbook: Ref(id=181388642139243008, class=Ref(id=spellbooks, class=Ref(id=classes))) } },
  { ref: Ref(id=181388642088911360, class=Ref(id=spells, class=Ref(id=classes))),
    ts: 1509244539235128,
    data:
     { name: "Hippo's Wallow",
       element: [ "water", "earth" ] } } ]