Created
April 23, 2019 22:57
-
-
Save patrickarlt/8d350e181f212b2698dec824f6da103e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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