I'm getting into GraphDB and I've just started making use of Gremlin alongside NeptuneDB to build a demo application.
I've been running into an issue for a while now, first is:
- I'm sending data to the Neptune DB that contains Nested Objects / Array of Nested Objects, what's the better way to run a Gremlin query that creates a property with the objects therein?
What I've had to do is write an algorithm that checks if i'm sending objects, then I stringify the object before sending,
Then whenever I'm receiving back the data, I parse the values from the keys
function generateGremlinPostArticleQuery(data) { let query = `g.addV('article')`; for (const key in data) { if (data.hasOwnProperty(key)) { if (typeof data[key] === 'object') { query += `.property('${key}', '${JSON.stringify(data[key])}')`; continue; } query += `.property('${key}', '${data[key]}')`; } } return query;}
function generateGremlinPostArticleQuery(data) { let query = `g.addV('article')`; for (const key in data) { if (data.hasOwnProperty(key)) { if (typeof data[key] === 'object') { query += `.property('${key}', '${JSON.stringify(data[key])}')`; continue; } query += `.property('${key}', '${data[key]}')`; } } return query;}
Secondly: How can I escape the apostrophe in my strings " ' "? I know of using the forward slashes \'...but this doesn't work accurately when I have nested JSON. Or different data structures across my request body
P:S - I'm a beginner with GraphDB and would appreciate references to using Gremlin/NeptuneDB as well as there aren't enough documentation out there
Recent Announcements
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community
AT
Apache TinkerPop
Apache TinkerPop is an open source graph computing framework and the home of the Gremlin graph query language.