-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
296bea6
commit e76eced
Showing
5 changed files
with
261 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const columnar = require("couchbase-columnar") | ||
|
||
async function main() { | ||
// Update this to your cluster | ||
const clusterConnStr = 'couchbases://--your-instance--' | ||
const username = 'username' | ||
const password = 'P@ssw0rd_12345!' | ||
// User Input ends here. | ||
|
||
const credential = new columnar.Credential(username, password) | ||
const scope = columnar | ||
.createInstance(clusterConnStr, credential, { | ||
securityOptions: { | ||
trustOnlyCertificates: columnar.Certificates.getNonprodCertificates(), | ||
}, | ||
}) | ||
.database("travel-sample") | ||
.scope("inventory") | ||
|
||
// Execute a streaming query with positional arguments. | ||
let qs = "SELECT * FROM airline LIMIT 10;" | ||
let res = await scope.executeQuery(qs) | ||
for await (let row of res.rows()) { | ||
console.log("Found row: ", row) | ||
} | ||
console.log("Metadata: ", res.metadata()) | ||
|
||
// Execute a streaming query with positional arguments. | ||
qs = "SELECT * FROM airline WHERE country=$1 LIMIT $2;" | ||
res = await scope.executeQuery(qs, { parameters: ["United States", 10] }) | ||
for await (let row of res.rows()) { | ||
console.log("Found row: ", row) | ||
} | ||
console.log("Metadata: ", res.metadata()) | ||
|
||
// Execute a streaming query with named parameters. | ||
qs = "SELECT * FROM airline WHERE country=$country LIMIT $limit;" | ||
res = await scope.executeQuery(qs, { | ||
parameters: { country: "United States", limit: 10 }, | ||
}) | ||
for await (let row of res.rows()) { | ||
console.log("Found row: ", row) | ||
} | ||
console.log("Metadata: ", res.metadata()) | ||
} | ||
|
||
main() | ||
.then(() => { | ||
console.log("Finished. Exiting app...") | ||
}) | ||
.catch((err) => { | ||
console.log("ERR: ", err) | ||
console.log("Exiting app...") | ||
process.exit(1) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Certificates, Credential, createInstance } from "couchbase-columnar" | ||
|
||
async function main() { | ||
// Update this to your cluster | ||
const clusterConnStr = 'couchbases://--your-instance--' | ||
const username = 'username' | ||
const password = 'P@ssw0rd_12345!' | ||
// User Input ends here. | ||
|
||
const credential = new Credential(username, password) | ||
const scope = createInstance(clusterConnStr, credential, { | ||
securityOptions: { | ||
trustOnlyCertificates: Certificates.getNonprodCertificates(), | ||
}, | ||
}) | ||
.database("travel-sample") | ||
.scope("inventory") | ||
|
||
// Execute a streaming query with positional arguments. | ||
let qs = "SELECT * FROM airline LIMIT 10;" | ||
let res = await scope.executeQuery(qs) | ||
for await (let row of res.rows()) { | ||
console.log("Found row: ", row) | ||
} | ||
console.log("Metadata: ", res.metadata()) | ||
|
||
// Execute a streaming query with positional arguments. | ||
qs = "SELECT * FROM airline WHERE country=$1 LIMIT $2;" | ||
res = await scope.executeQuery(qs, { parameters: ["United States", 10] }) | ||
for await (let row of res.rows()) { | ||
console.log("Found row: ", row) | ||
} | ||
console.log("Metadata: ", res.metadata()) | ||
|
||
// Execute a streaming query with named parameters. | ||
qs = "SELECT * FROM airline WHERE country=$country LIMIT $limit;" | ||
res = await scope.executeQuery(qs, { | ||
parameters: { country: "United States", limit: 10 }, | ||
}) | ||
for await (let row of res.rows()) { | ||
console.log("Found row: ", row) | ||
} | ||
console.log("Metadata: ", res.metadata()) | ||
} | ||
|
||
main() | ||
.then(() => { | ||
console.log("Finished. Exiting app...") | ||
}) | ||
.catch((err) => { | ||
console.log("ERR: ", err) | ||
console.log("Exiting app...") | ||
process.exit(1) | ||
}) |