• Blog
  • Documentation
  • Pricing
  • Help Center
  • Create an Account
  • Log in
Docs Menu
  • Intro
    • What, Why, and How
    • Feature Overview
    • Using the Console
    • Using the Command-line
    • API Clients
    • Custom Domains
    • Environments
  • Deploy
    • Getting Started
    • Configuring Deployments
    • Continuous Deployment
    • Deploying Node.js
    • Deploying Ruby
    • Deploying Java
    • Deploying Liferay DXP
    • Deploying Docker
  • Auth
    • Getting Started
    • Manage Users
    • Sign-in With Password
    • Sign-in With Facebook
    • Sign-in With Google
    • Sign-in With GitHub
    • Environment Variables
  • Data
    • Getting Started
    • Configuring Data
    • Saving Data
    • Getting Data
    • Realtime Data
    • Searching Data
    • Filtering Data
    • Updating Data
    • Deleting Data
    • Environment Variables
  • Email
    • Getting Started
    • Sending Email
    • Checking Status
    • Environment Variables
  • Hosting
    • Getting Started
    • Custom Error Pages
    • Environment Variables

Data Guide

Getting Data

Get an existing field, document or collection in the database.

If you are unfamiliar with our API, please visit the API Clients page first to learn how to install and configure it.

Get Collection

It is simple and easy to start getting documents from your saved data collections. You simply use the get method in your WeDeploy API call and then pass the name of the collection you want to retrieve.

WeDeploy
  .data('https://-.wedeploy.io')
  .get('movies')
  .then(function(movie) {
    console.log(movie);
  });
WeDeploy
  .data('https://-.wedeploy.io')
  .get(resourcePath: "movies")
  .then { movie in
    print(movie)
  }
WeDeploy
  .data("https://-.wedeploy.io")
  .get("movies")
  .execute();
curl -X "GET" "https://-.wedeploy.io/movies" \
     -H 'Authorization: Bearer ' \

The response will give you all the documents inside that collection.

[
  {"id":"star_wars_i", "title":"Star Wars: Episode I - The Phantom Menace", "year":1999, "rating":6.5},
  {"id":"star_wars_ii", "title":"Star Wars: Episode II - Attack of the Clones", "year":2002, "rating":6.7},
  {"id":"star_wars_iii", "title":"Star Wars: Episode III - Revenge of the Sith", "year":2005, "rating":7.7},
  {"id":"star_wars_iv", "title":"Star Wars: Episode IV - A New Hope", "year":1977, "rating":8.7},
  {"id":"star_wars_v", "title":"Star Wars: Episode V - The Empire Strikes Back", "year":1980, "rating":8.8},
  {"id":"star_wars_vi", "title":"Star Wars: Episode VI - Return of the Jedi", "year":1983, "rating":8.4},
  {"id":"star_wars_vii", "title":"Star Wars: Episode VII - The Force Awakens", "year":2015}
]

Get with Data Path

We can also get any document body or document field value using the full data path (collection/documentId/documentField):

WeDeploy
  .data('https://-.wedeploy.io')
  .get('movies/star_wars_v/title')
  .then(function(title) {
    console.log(title);
  });
WeDeploy
  .data('https://-.wedeploy.io')
  .get(resourcePath: "movies/star_wars_v/title")
  .then { (movie: String) in // You have to specify the type here to allow compiler infer type
    print(movie)
  }
WeDeploy
  .data('https://-.wedeploy.io')
  .get("movies/star_wars_v/title")
  .execute();
curl -X "GET" "https://-.wedeploy.io/movies/star_wars_v/title" \
     -H 'Authorization: Bearer ' \

Sorting and Filtering

When you request to get a collection, all the documents inside that collection will be sent to you ordered by the date they were created (createdAt). So what if you want to filter or sort your results?

Sorting

Below you can see an example of sorting the results from your request in descending order based on the rating field.

WeDeploy
  .data('https://-.wedeploy.io')
  .orderBy('rating', 'desc')
  .get('movies')
  .then(function(movies) {
    console.log(movies);
  });
WeDeploy
  .data('https://-.wedeploy.io')
  .orderBy(field: "rating", order: .DESC)
  .get(resourcePath: "movies")
  .then { movies in
    print(movies)
  }
WeDeploy
  .data("https://-.wedeploy.io")
  .orderBy("rating", SortOrder.DESCENDING)
  .get("movies")
  .execute();
curl -X "GET" "https://-.wedeploy.io/movies" \
     -H 'Authorization: Bearer ' \
     --get \
     --data-urlencode $'sort=[
        {
          "rating": "desc"
        }
      ]'

The result would be the following list if documents sorted by rating.

[
  {"id":"star_wars_v","title":"Star Wars: Episode V - The Empire Strikes Back","year":1980,"rating":8.8},
  {"id":"star_wars_iv","title":"Star Wars: Episode IV - A New Hope","year":1977,"rating":8.7},
  {"id":"star_wars_vi","title":"Star Wars: Episode VI - Return of the Jedi","year":1983,"rating":8.4},
  {"id":"star_wars_iii","title":"Star Wars: Episode III - Revenge of the Sith","year":2005,"rating":7.7},
  {"id":"star_wars_ii","title":"Star Wars: Episode II - Attack of the Clones","year":2002,"rating":6.7},
  {"id":"star_wars_i","title":"Star Wars: Episode I - The Phantom Menace","year":1999,"rating":6.5},
  {"id":"star_wars_vii","title":"Star Wars: Episode VII - The Force Awakens","year":2015}
]

Filtering

You can also provide filters so that only documents that match your query will be returned in the result.

WeDeploy
  .data('https://-.wedeploy.io')
  .where('year', '<', 2000)
  .or('rating', '>', 8.5)
  .get('movies')
  .then(function(movies) {
    console.log(movies);
  });
WeDeploy
  .data('https://-.wedeploy.io')
  .where(field: "year", op: "<", value: 2000)
  .or(field: "rating", op: ">", value: 8.5)
  .get(resourcePath: "movies")
  .then { movies in
    print(movies)
  }
WeDeploy
  .data("https://-.wedeploy.io")
  .where(lt("year", 2000).or(gt("rating", 8.5)))
  .get("movies")
  .execute();
curl -X "GET" "https://-.wedeploy.io/movies" \
     -H 'Authorization: Bearer ' \
     --get \
     --data-urlencode $'filter=[
        {
          "or": [
            {
              "year": {
                "value": 2000,
                "operator": "<"
              }
            },
            {
              "rating": {
                "value": 8.5,
                "operator": ">"
              }
            }
          ]
        }
      ]'

The result will be any documents from that collection that match these filter parameters.

[
  {"id":"star_wars_iv","title":"Star Wars: Episode IV - A New Hope","year":1977,"rating":8.7},
  {"id":"star_wars_v","title":"Star Wars: Episode V - The Empire Strikes Back","year":1980,"rating":8.8}
]

For more examples of useful filters and result sorting you can use, see our Filtering Data page.

What's next?

Now that you've learned how to retrieve, you can start using real-time.

Was this section helpful?

Contribute on Github! Edit this section.

Couldn't find what you want?

Don't worry, we're constantly working on improvements. Stay tuned!