Comparing version 0.9.1 to 0.9.2
{ | ||
"name": "sajari", | ||
"version": "0.9.1", | ||
"version": "0.9.2", | ||
"description": "JavaScript SDK for access to the Sajari search API", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -36,7 +36,7 @@ # sajari-sdk-js | ||
var args = { | ||
q : "something" | ||
}; | ||
var query = api.query({ | ||
'q': 'whatever' | ||
}) | ||
api.search(args, function success(res) { | ||
api.search(query, function success(res) { | ||
console.log(res); | ||
@@ -61,7 +61,7 @@ }, function failure(err) { | ||
var args = { | ||
q : "something" | ||
}; | ||
var query = api.query({ | ||
'q': 'whatever' | ||
}) | ||
api.search(args, function success(res) { | ||
api.search(query, function success(res) { | ||
console.log(res); | ||
@@ -78,16 +78,8 @@ }, function failure(err) { | ||
### Args | ||
### Query object | ||
Creating a new `query` object from the initialized API is very simple: | ||
```js | ||
var query = api.query(opts); | ||
``` | ||
A new `query` object can be initialized with `opts`: | ||
`opts` can be a query string: | ||
`opts` can be an object: | ||
```js | ||
var query = api.query('something'); | ||
``` | ||
`opts` also allows an object of args to be passed directly: | ||
```js | ||
var query = api.query({ | ||
@@ -100,4 +92,9 @@ q : 'something', | ||
Sajari has many [supported attributes](https://www.sajari.com/api-documentation#attributes). Many have convenience wrappers as per below, these can also be chained: | ||
`opts` can also be a query string: | ||
```js | ||
var query = api.query('something'); | ||
``` | ||
Sajari has many [supported attributes](https://www.sajari.com/api-documentation#attributes) with query methods. These can also be chained: | ||
```js | ||
var query = api.query('something') | ||
@@ -121,3 +118,3 @@ .filter("this", "~", "that") | ||
In the above case, the query is passed directly to the search function, which will decode it automatically into args. | ||
In the above case, the query is passed directly to the search function, which handles the appropriate encoding for you. | ||
@@ -136,3 +133,3 @@ | ||
Instant search example (should be triggered as people type): | ||
Instant search example (should be triggered using the keyup event or similar): | ||
```js | ||
@@ -139,0 +136,0 @@ var query = api.query('di'); |
@@ -7,2 +7,7 @@ var isArray = require('./utils/isArray'); | ||
function query(options) { | ||
if (typeof options === 'string') { | ||
options = { | ||
q: options | ||
}; | ||
} | ||
if (options === undefined) { | ||
@@ -9,0 +14,0 @@ options = {}; |
@@ -109,1 +109,7 @@ | ||
var query6 = api.query('disco'); | ||
test('Query encoding 6', function (t) { | ||
var enc = query6.encode(); | ||
t.equal(enc["q"], "disco"); | ||
t.end(); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38597
1108
206