Skip to content

Commit

Permalink
feat(update-protocol): using consumption
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo Valentim authored and RoValentim committed Feb 14, 2019
1 parent 12d657c commit 1288c87
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
11 changes: 6 additions & 5 deletions extra_docs/examples/javascript/node/node-example.js
Expand Up @@ -3,20 +3,21 @@ const jexiaSDK = require('../../../../dist/node');

const jexiaClient = jexiaSDK.jexiaClient;
const dataOperations = jexiaSDK.dataOperations;
const dataSetName = "dataset";

//Initialize DataOperationsModule
let dom = dataOperations();
let credentials = {
projectID: "test",
key: "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
secret: "a_secret"
projectID: "3d53988c-3544-4d27-9782-f05e73e5581b",
key: "b9bccc78-8376-4050-a2c1-e814c0d6af4c",
secret: "eY0BAYcUPqCZKRzRCan9CSwA4y45/PtWis6YaSKjSaMVzxwO0fjw2kn9uDfYuQBNtXspBJT2YKw9sMCgCHpm7Q=="
};

//Initialize Client and pass DataOperationsModule to it.
jexiaClient().init(credentials, dom);

dom.dataset("d1")
.insert([{ name: "field1" }, { name: "field2" }])
dom.dataset(dataSetName)
.insert({ "field": "Some value" })
.execute()
.then((records) => {
console.log("Records are inserted:\n=======================\n", records);
Expand Down
4 changes: 4 additions & 0 deletions src/api/dataops/queries/baseQuery.ts
Expand Up @@ -68,6 +68,10 @@ export abstract class BaseQuery<T> {
private get compiledRequest(): ICompiledRequest<T> {
const compiledQuery = this.query.compile();

if (this.records && !Object.keys(compiledQuery).length) {
return Object.assign(this.records);
}

return Object.assign(
{ action: this.action },
Object.keys(compiledQuery).length && { params: compiledQuery },
Expand Down
6 changes: 3 additions & 3 deletions src/api/dataops/queries/insertQuery.spec.ts
Expand Up @@ -44,8 +44,8 @@ describe("InsertQuery class", () => {
let subject: any = new InsertQuery(qe, [{ title: "Another first post", user_id: 1 }], dataset);
spyOn(subject["queryExecuter"], "executeRequest");
subject.execute();
expect(subject["queryExecuter"].executeRequest).toHaveBeenLastCalledWith({
action: "insert", records: subject["records"]
});
expect(subject["queryExecuter"].executeRequest).toHaveBeenLastCalledWith([{
title: "Another first post", user_id: 1
}]);
});
});

0 comments on commit 1288c87

Please sign in to comment.