Prerequisites
- TerminusDB running locally — see Docker setup for instructions
- The TerminusDB JavaScript client installed (installation guide)
- A database with existing documents
What you'll achieve By the end of this guide, you will have queried documents from your database using the JavaScript client's document interface.
Get a list of documents matching a query. For more advanced queries, take a look at the GraphQL and WOQL how-to guides.
Example: JavaScript
const queryDocuments = async () => {
const queryTemplate = { "@type": "Player", "position": "Full Back" }
const result = await client.getDocument({"as_list":true,"query":queryTemplate});
console.log("Query Documents",result)
}Example: JSON
[{"@type" : "Player",
"name" : "Doug",
"position" : "Full Back"}]Next steps
- GraphQL queries — query with field selection, filtering, and nested traversal
- WOQL queries — pattern-match across documents and relationships using Datalog
- Edit documents — update documents you've retrieved
- Get documents — retrieve documents by ID or type (without a query template)