1 réponse
- Le plus récent
- Le plus de votes
- La plupart des commentaires
0
One thing to note is that you're not currently leveraging user-defined IDs. If you have some aspect of your data that is unique across all vertices/edges, the it is best to attempt to use that as a user-defined ID. It will make doing a vertex lookup easier, later on. You can define a user-defined ID by importing id from the t library:
const { t: { id } } = gremlin.process;
and creating an id property as follows:
await g.addV('Person').property(id, 'personid-1234567').property('gender', 'string').property('dob', 'string').next();
Whether you use a user-generated ID or a Neptune-generated ID, you'll need these IDs to create your edges:
await g.addE('knows').from(V('person-123456')).to(V('person-654321')).property('since','2023-01-02').next();
You can also build up relationships in the same query as when defining your vertices through the use of query labels:
await g.addV('Person').property(id, 'personid-1234567').property('gender', 'string').property('dob', 'string').as('a').
addV('Person').property(id, 'personid-654321').property('gender', 'string').property('dob', 'string').as('b').
addE('knows').from('a').to('b').property('since','2023-01-02').next();
Here's a good resource for learning how to use Gremlin: https://www.kelvinlawrence.net/book/PracticalGremlin.html
répondu il y a 4 mois
Contenus pertinents
- demandé il y a un an
- demandé il y a 9 mois
- demandé il y a un an
- AWS OFFICIELA mis à jour il y a un an
- AWS OFFICIELA mis à jour il y a un an
- AWS OFFICIELA mis à jour il y a 5 mois
- AWS OFFICIELA mis à jour il y a 3 ans
Thank you so much for your response Taylor