Singleton

Copied!
( ref )

Description

The Singleton function produces a set containing the ref that you provide.

In most cases, functions cast refs into sets when necessary. The only case where Singleton is required is to return a set’s events rather than a ref’s events.

Parameters

Argument Type Definition and Requirements

ref

Ref

A reference to a resource, such as a document, collection, database, etc.

Returns

A SetRef for the single ref.

Examples

The following query creates a single item set from the provided ref:

Copied!
client.query(
  q.(q.(q.('posts'), '233286601218720256'))
)
.then((ret) => console.log(ret))
SetRef({ singleton: (("posts"), "233286601218720256") })

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!