### Install BV-BRC JS Client via npm Source: https://github.com/bv-brc/bvbrc_js_client/blob/main/README.md Installs the bvbrc_js_client library using the npm package manager. ```shell npm install bvbrc_js_client ``` -------------------------------- ### Querying Genomes with Wrapper Method - JavaScript Source: https://github.com/bv-brc/bvbrc_js_client/blob/main/README.md Shows examples of using the `svc.queryGenomes` wrapper method to query for genome records. It demonstrates different query styles including PQL (Pattern Query Language), keyword search, and explicit SOLR queries, along with options like `limit` and `start`. ```JavaScript const result = await svc.queryGenomes("eq(genome_id,227377.26)") const result = await svc.queryGenomes("keyword(coxiella)",{limit: 10}) const result = await svc.queryGenomes("coxiella",{limit: 10, start:5, query_lang: "solr"}) ``` -------------------------------- ### Get Single Item using Async/Await Source: https://github.com/bv-brc/bvbrc_js_client/blob/main/README.md Retrieves a single item of a specified data type by its unique ID using the get method with async/await syntax. ```javascript var genome = await svc.get("genome","227377.26") console.log(`Genome: ${genome}`) ``` -------------------------------- ### Getting Single Genome by ID - JavaScript Source: https://github.com/bv-brc/bvbrc_js_client/blob/main/README.md Illustrates the use of the data type-specific wrapper method `svc.getGenome` to fetch a single genome record by its unique identifier. This method is a convenience wrapper around the base `get` method. ```JavaScript const genome = await svc.getGenome("227377.26") ``` -------------------------------- ### Get Schema using Async/Await Source: https://github.com/bv-brc/bvbrc_js_client/blob/main/README.md Retrieves the SOLR schema for a specified data type (e.g., 'genome') using the getSchema method with async/await syntax. ```javascript var schema = await svc.getSchema('genome') ``` -------------------------------- ### Querying Data with Base Method (SOLR) - JavaScript Source: https://github.com/bv-brc/bvbrc_js_client/blob/main/README.md Demonstrates using the generic `svc.query` method to retrieve data from a specified collection ('genome') using a SOLR query string. It logs the query metadata (total items, start index) and the returned items. ```JavaScript var result = await svc.query("genome","genome_id:227377.26") console.log(`Query Metadata - Total Items: ${result.meta.total_items} Start: ${result.meta.start}`) console.log("Genomes: ", result.items) ``` -------------------------------- ### Get Single Item using Promises Source: https://github.com/bv-brc/bvbrc_js_client/blob/main/README.md Retrieves a single item of a specified data type by its unique ID using the get method with promise syntax (.then()). ```javascript svc.get("genome","227377.26").then((genome)=>{ console.log(`Genome: ${genome}`) }) ``` -------------------------------- ### Instantiate Client Lazily Source: https://github.com/bv-brc/bvbrc_js_client/blob/main/README.md Illustrates how to instantiate the client without parameters and initialize it later with the endpoint and token, suitable for singleton patterns. ```javascript const svc = new BVBRCClient(); /* later */ svc.init(endpoint, token) ``` -------------------------------- ### Instantiate Client in NodeJS Source: https://github.com/bv-brc/bvbrc_js_client/blob/main/README.md Shows how to require and create a new instance of the BV-BRC client in a NodeJS environment, specifying the API endpoint. ```javascript const Service = require('bvbrc_js_client') const svc = new Service("https://patricbrc.org/api") ``` -------------------------------- ### Instantiate Client in Browser Source: https://github.com/bv-brc/bvbrc_js_client/blob/main/README.md Shows how to create a new instance of the BVBRCClient class in a browser environment after including the standalone script. ```javascript const svc = new BVBRCClient("https://patricbrc.org/api") ``` -------------------------------- ### Run Library Tests Source: https://github.com/bv-brc/bvbrc_js_client/blob/main/README.md Executes the test suite for the bvbrc_js_client library. ```shell npm run test ``` -------------------------------- ### Include Client in Browser (Script Tag) Source: https://github.com/bv-brc/bvbrc_js_client/blob/main/README.md Demonstrates how to include the pre-built standalone client library in an HTML page using a script tag. ```html ``` -------------------------------- ### Build Standalone Browser Version Source: https://github.com/bv-brc/bvbrc_js_client/blob/main/README.md Runs the build script to create a standalone JavaScript file for browser use in the 'dist' folder. ```shell npm run build ``` -------------------------------- ### Query Data with RQL using Promises Source: https://github.com/bv-brc/bvbrc_js_client/blob/main/README.md Executes a query against a specified data type using an RQL query string and retrieves results using promise syntax (.then()). ```javascript svc.query("genome","eq(genome_id,227377.26)").then((result)=>{ console.log(`Query Metadata - Total Items: ${result.meta.total_items} Start: ${result.meta.start}`) console.log("Genomes: ", result.items) }) ``` -------------------------------- ### Query Data with RQL using Async/Await Source: https://github.com/bv-brc/bvbrc_js_client/blob/main/README.md Executes a query against a specified data type using an RQL query string and retrieves results using async/await syntax. ```javascript var result = await svc.query("genome","eq(genome_id,227377.26)") console.log(`Query Metadata - Total Items: ${result.meta.total_items} Start: ${result.meta.start}`) console.log("Genomes: ", result.items) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.