Skip to content

Instantly share code, notes, and snippets.

@patrickarlt
Created April 23, 2019 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickarlt/8d350e181f212b2698dec824f6da103e to your computer and use it in GitHub Desktop.
Save patrickarlt/8d350e181f212b2698dec824f6da103e to your computer and use it in GitHub Desktop.
require("isomorphic-fetch");
require("isomorphic-form-data");
const { SearchQueryBuilder, searchItems } = require("@esri/arcgis-rest-portal");
const { UserSession } = require("@esri/arcgis-rest-auth");
const username = "test";
const password = "test"
(async function() {
const session = new UserSession({
username,
password
});
var q = new SearchQueryBuilder()
.match("test")
.and()
.match(session.username)
.in("owner")
.not()
.match("public")
.in("access");
console.log(q.toParam()); // test AND owner: patrickarlt7104 NOT access: public
var { results } = await searchItems({
q,
authentication: session,
num: 100
});
console.log(results.length); // 93
var q = new SearchQueryBuilder()
.match("test")
.and()
.match(session.username)
.in("owner")
.and()
.match("public")
.in("-access");
console.log(q.toParam()); // test AND owner: patrickarlt7104 AND -access: public
var { results } = await searchItems({
q,
authentication: session,
num: 100
});
console.log(results.length); // 93
var q = `test AND owner: ${session.username} AND NOT access: public`;
console.log(q); // test AND owner: patrickarlt7104 AND -access: public
var { results } = await searchItems({
q,
authentication: session,
num: 100
});
console.log(results.length); // 93
var q = `test AND owner: ${session.username} AND -access: public`;
console.log(q); // test AND owner: patrickarlt7104 AND -access: public
var { results } = await searchItems({
q,
authentication: session,
num: 100
});
console.log(results.length); // 93
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment