Sails-ArangoJs

Sails-ArangoJs

  • Docs
  • API

›CRUD API

Getting Started

  • Installation
  • Creating Models
  • Testing

CRUD API

  • let
  • create
  • createEach
  • update
  • updateOne
  • upsert
  • find
  • findOne
  • sum
  • avg
  • destroy
  • count
  • aggregate
  • sample
  • findNear
  • findWithCount

Graph & Transactions

  • Implementing transacations
  • Graph

Going Native

  • Native Methods
  • Foxx Services

The sample of a numeric attribute

sample Method

The method used to get sample records from your collection. A filter criteria can be used to filter before sampling.

Please refer the find method on how to use the filter criteria.

The select method can be used to specify the attributes you would like to return.

Usage

const documents = await Product.sample({
  price: { $gt: 2000 }
}).limit(5);

// Do something with the documents.

The above method samples the product collection for 5 documents.

const documents = await Product.sample({
  price: { $gt: 2000 }
}).limit(5).select(['ProductName])

// Do something with created records.

The above method samples the price attribute of the model cart where category of the products is groceries.

Please refer to the find methods for the operators that can be implemented in the criteria.

← aggregatefindNear →
  • sample Method
    • Usage
Sails-ArangoJs
Docs
Getting StartedAPI Reference
Community
User ShowcaseStack OverflowTwitter
More
BlogGitHub
Cloudhub Developer Community
Copyright © 2022 Cloud Hub Limited