dgraph-js-extras
Advanced tools
Comparing version 0.6.3 to 0.6.4
@@ -0,1 +1,11 @@ | ||
<a name="0.6.4"></a> | ||
## [0.6.4](https://github.com/vespertilian/dgraph-js-extras/compare/v0.6.3...v0.6.4) (2019-01-28) | ||
### Features | ||
* **upsert-edge-list validate-node-exists:** added upsert-edge-list and validate-node-exists functio ([f42fa05](https://github.com/vespertilian/dgraph-js-extras/commit/f42fa05)) | ||
<a name="0.6.3"></a> | ||
@@ -2,0 +12,0 @@ ## [0.6.3](https://github.com/vespertilian/dgraph-js-extras/compare/v0.6.2...v0.6.3) (2019-01-21) |
@@ -7,2 +7,3 @@ export { xQueryWithVars, xQueryWithVarsTxn, xQuery, xQueryTxn } from './query/query'; | ||
export { xUpsertTxn } from './upsert/upsert'; | ||
export { xUpsertEdgeList, xUpsertEdgeListTxn } from './upsert-edge-list/upsert-edge-list'; | ||
export { xUpsertMapTxn } from './upsert-map/upsert-map'; | ||
@@ -16,2 +17,3 @@ export { xGetSchemaMapTxn } from './get-schema-map/get-schema-map'; | ||
export { xSetupWithSchemaDataNowTxn } from './test-helpers/setup'; | ||
export { xValidateNodeExists, xValidateNodeExistsTxn } from './validate-node-exists/validate-node-exists'; | ||
export { xValidateNodePredicates, xValidateNodePredicatesTxn } from './validate-node-predicates/validate-node-predicates'; | ||
@@ -18,0 +20,0 @@ export { xValidateNodeLinks, xValidateNodeLinksTxn } from './validate-node-links/validate-node-links'; |
@@ -19,2 +19,5 @@ "use strict"; | ||
exports.xUpsertTxn = upsert_1.xUpsertTxn; | ||
var upsert_edge_list_1 = require("./upsert-edge-list/upsert-edge-list"); | ||
exports.xUpsertEdgeList = upsert_edge_list_1.xUpsertEdgeList; | ||
exports.xUpsertEdgeListTxn = upsert_edge_list_1.xUpsertEdgeListTxn; | ||
var upsert_map_1 = require("./upsert-map/upsert-map"); | ||
@@ -40,2 +43,5 @@ exports.xUpsertMapTxn = upsert_map_1.xUpsertMapTxn; | ||
exports.xSetupWithSchemaDataNowTxn = setup_2.xSetupWithSchemaDataNowTxn; | ||
var validate_node_exists_1 = require("./validate-node-exists/validate-node-exists"); | ||
exports.xValidateNodeExists = validate_node_exists_1.xValidateNodeExists; | ||
exports.xValidateNodeExistsTxn = validate_node_exists_1.xValidateNodeExistsTxn; | ||
var validate_node_predicates_1 = require("./validate-node-predicates/validate-node-predicates"); | ||
@@ -42,0 +48,0 @@ exports.xValidateNodePredicates = validate_node_predicates_1.xValidateNodePredicates; |
import * as dgraph from 'dgraph-js'; | ||
import { Txn } from 'dgraph-js'; | ||
export interface INodeFoundFunction { | ||
@@ -12,1 +13,2 @@ existingUid: string | null; | ||
export declare function xUpsertTxn(upsertFn: (input?: any) => IUpsertFnReturnValues, data: object, dgraphClient: dgraph.DgraphClient, _dgraph?: any): Promise<string>; | ||
export declare function xUpsertObject(upsertFn: (input?: any) => IUpsertFnReturnValues, node: object, transaction: Txn): Promise<string | null>; |
@@ -163,3 +163,3 @@ "use strict"; | ||
// Rethrow the error but with more context about exactly what failed | ||
throw new Error("xUpsert DgraphQuery failed, check the query your provided against this error: " + e); | ||
throw new Error("xUpsert DgraphQuery failed, check the query you provided against this error: " + e); | ||
})]; | ||
@@ -198,1 +198,2 @@ case 1: | ||
} | ||
exports.xUpsertObject = xUpsertObject; |
{ | ||
"name": "dgraph-js-extras", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"description": "Functions to use with dgraph", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -7,2 +7,3 @@ export {xQueryWithVars, xQueryWithVarsTxn, xQuery, xQueryTxn} from './query/query' | ||
export {xUpsertTxn} from './upsert/upsert' | ||
export {xUpsertEdgeList, xUpsertEdgeListTxn} from './upsert-edge-list/upsert-edge-list'; | ||
export {xUpsertMapTxn} from './upsert-map/upsert-map' | ||
@@ -16,2 +17,3 @@ export {xGetSchemaMapTxn} from './get-schema-map/get-schema-map' | ||
export {xSetupWithSchemaDataNowTxn} from './test-helpers/setup' | ||
export {xValidateNodeExists, xValidateNodeExistsTxn} from './validate-node-exists/validate-node-exists'; | ||
export {xValidateNodePredicates, xValidateNodePredicatesTxn} from './validate-node-predicates/validate-node-predicates'; | ||
@@ -18,0 +20,0 @@ export {xValidateNodeLinks, xValidateNodeLinksTxn} from './validate-node-links/validate-node-links'; |
import {xSetupForTest} from '../test-helpers/setup'; | ||
import {xSetSchemaAlt} from '../set-schema/set-schema'; | ||
import {xSetJSON, xSetJSONNow, xSetJSONNowTxn} from './set-json'; | ||
import { xExtractFirstUid } from '../extract-uids/extract-uids'; | ||
import { xQueryTxn } from '../query/query'; | ||
@@ -106,3 +108,4 @@ describe('xSetJSON', () => { | ||
expect(queryRes.getJson().q).toEqual([data]) | ||
}) | ||
}); | ||
}); | ||
@@ -134,3 +137,74 @@ | ||
expect(queryRes.getJson().q).toEqual([data]) | ||
}); | ||
it('lets you set nested objects', async() => { | ||
const {dgraphClient} = await xSetupForTest(); | ||
const person = { | ||
name: "Alice", | ||
age: 26, | ||
loc: "Riley Street", | ||
married: true, | ||
schools: [ | ||
{ | ||
name: "Crown Public School", | ||
}, | ||
], | ||
friends: [ | ||
{ | ||
name: "Bob", | ||
age: 24, | ||
}, | ||
{ | ||
name: "Charlie", | ||
age: 29, | ||
}, | ||
], | ||
}; | ||
const person2 = { | ||
name: "Bob", | ||
age: 24, | ||
loc: "Riley Street", | ||
married: true, | ||
schools: [ | ||
{ | ||
name: "Crown Public School", | ||
}, | ||
], | ||
friends: [ | ||
{ | ||
name: "Alice", | ||
age: 26, | ||
}, | ||
{ | ||
name: "Charlie", | ||
age: 29, | ||
}, | ||
], | ||
}; | ||
const uid = await xExtractFirstUid(xSetJSONNowTxn([person, person2], dgraphClient)); | ||
const personQuery = `{ | ||
q(func: uid(${uid})) { | ||
uid | ||
name | ||
age | ||
loc | ||
married | ||
friends { | ||
uid | ||
name | ||
age | ||
} | ||
schools { | ||
uid | ||
name | ||
} | ||
} | ||
}`; | ||
const result = await xQueryTxn(personQuery, dgraphClient); | ||
}) | ||
}); |
@@ -59,4 +59,4 @@ import {xSetupForTest} from '../test-helpers/setup'; | ||
expect(error.message).toContain('xUpsert DgraphQuery failed, check the query your provided against this error:') | ||
expect(error.message).toContain('xUpsert DgraphQuery failed, check the query you provided against this error:') | ||
}) | ||
}); |
@@ -51,2 +51,3 @@ import * as dgraph from 'dgraph-js' | ||
} | ||
return results | ||
@@ -80,3 +81,3 @@ } | ||
async function xUpsertObject(upsertFn: (input?: any) => IUpsertFnReturnValues, node: object, transaction: Txn): Promise<string | null> { | ||
export async function xUpsertObject(upsertFn: (input?: any) => IUpsertFnReturnValues, node: object, transaction: Txn): Promise<string | null> { | ||
let result = null; | ||
@@ -88,3 +89,3 @@ | ||
// Rethrow the error but with more context about exactly what failed | ||
throw new Error(`xUpsert DgraphQuery failed, check the query your provided against this error: ${e}`) | ||
throw new Error(`xUpsert DgraphQuery failed, check the query you provided against this error: ${e}`) | ||
}); | ||
@@ -91,0 +92,0 @@ |
@@ -51,3 +51,3 @@ import {xSetupWithSchemaDataNowTxn} from '../test-helpers/setup'; | ||
it('returns false when you nodes are missing the predicate', async() => { | ||
it('returns false when nodes are missing the predicate', async() => { | ||
const result = await xValidateNodePredicatesTxn({ | ||
@@ -59,3 +59,3 @@ nodes: userUids, | ||
expect(result).toEqual(false) | ||
}) | ||
}); | ||
}); |
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
193148
95
4113