Spraypaint the isomorphic, framework-agnostic Graphiti ORM

Filtering

Use #where() to apply filters:

Post.where({ important: true }).all()

/posts?filter[important]=true

#where() clauses can be chained together. If the same key is seen twice, it will be overridden:

Post
  .where({ important: true })
  .where({ ranking: 10 })
  .where({ important: false })
  .all()

/posts?filter[important]=false&filter[ranking]=10

#where() clauses are based on server implementation. The key should be exactly as the server understands it. Here are some common conventions we promote:

// id greater than 5
Post.where({ id_gt: 5 }).all()

// id greater than or equal to 5
Post.where({ id_gte: 5 }).all()

// id less than 5
Post.where({ id_lt: 5 }).all()

// id less or equal to 5
Post.where({ id_lte: 5 }).all()

// title starts with "foo"
Post.where({ title: { prefix: "foo" } }).all()

// OR these two values
Post.where({ status_or: ['draft', 'review'] })

// AND these two values (default)
Post.where({ status: ['draft', 'review'] })

Escaping Values

Graphiti treats a comma as a delimiter of multiple values. To escape the comma and tell Graphiti this is a single value, wrap it in {{curlies}}:

Post.where({ title: "{{Hello World, here I am}}" })