GithubHelp home page GithubHelp logo

azure-samples / azure-cosmos-db-graph-nodejs-getting-started Goto Github PK

View Code? Open in Web Editor NEW
43.0 41.0 36.0 43 KB

Azure Cosmos DB's Graph API provides the graph data model and Gremlin. This tutorial shows how to get started with the Graph (Gremlin) API and the Node.js SDK.

License: MIT License

JavaScript 100.00%

azure-cosmos-db-graph-nodejs-getting-started's Introduction

languages page_type products description urlFragment
javascript
nodejs
sample
azure
azure-cosmos-db
How to use the Azure Cosmos DB with the Graph API to store and access data from a Node.js application.
developing-nodejs-gremlin

Develop a Node.js app with Gremlin Graph and Azure Cosmos DB

Azure Cosmos DB is a globally distributed multi-model database. One of the supported APIs is the Graph (Gremlin) API, which provides a graph data model with Gremlin query/traversals. This sample shows you how to use the Azure Cosmos DB with the Graph API to store and access data from a Node.js application.

Running this sample

  • Before you can run this sample, you must have the following prerequisites:

  • Then, clone this repository using git clone https://github.com/Azure-Samples/azure-cosmos-db-graph-nodejs-getting-started.git

  • Next, substitute the Gremlin endpoint (*.gremlin.cosmosdb.azure.com), your database and collection (graph) values, and primary master key in config.js with your Cosmos DB account's values.

  • From a command prompt or shell, run npm install from the root directory to install the gremlin-javascript and async modules, and their dependencies.

  • From a command prompt or shell, run node app.js to run the application and follow the instructions.

About the code

The code included in this sample is intended to get you quickly started with a Node.js application that connects to Azure Cosmos DB with the Graph (Gremlin) API.

More information

azure-cosmos-db-graph-nodejs-getting-started's People

Contributors

arramac avatar daveo1001 avatar dennyglee avatar druttka avatar jbmusso avatar johnpapa avatar ksivamuthu avatar luisbosquez avatar manishmsfte avatar microsoftopensource avatar mimig1 avatar msftgits avatar olivertowers avatar supernova-eng avatar vitoc avatar vivekr20 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-cosmos-db-graph-nodejs-getting-started's Issues

Error with gremlin version 3.2.9

Hello

i try to install the new version of gremlin (3.2.9) for use the gremlin fluent api.
When i try to execute the code , it give me an error.

Exists a new implementation or example?

Thanks

Andrea

Can't terminate the connection

There is no ability to end the websocket connection so it just hangs.

Can we add a close connection to gremlin-secure? I can't use this in an Azure Function until it's possible to terminate.

Open / Close connection & performance

Hi all, I noticed that if I open and close the connection on every request this is taking a bit long sometimes and with the serverless azure cosmo db it even hangs up completely sometimes. When I just keep the connection open for the runtime of my application, this is way more performant for single requests. Is this a valid implementation or how can this be solved? I am developing an API / Backend - Application with many requests that have to be performed in parallel.

New version of gremlin-javascript?

Do we know any ETA on when with cosmos support new version of gremlin-javascript? 3.4.10 or 3.5.0 ? that includes elementMap() etc?. Its been 4 years without any update to library or the service. Please advice.

Store Persian Text in Values

The problem is when I wanna store text which is in Persian into the Cosmos Graph through a gremlin query in node js, It is failed:

 GremlinDriver.execute("g.V(id).out('includes')
                        .hasLabel('play')
                        .property('test', field_value)", 
                       { id: '123456', field_value: field_value })

If the the field_value is in Persian Language like ("تست") I will get Gremlin Query Parse Error.

Cannot connect to gremlin db

I follow the steps of the documentation, but when I run node app.js I got nothing display, not even the logs of the queries (so I assume its not even starting the client). What could be wrong? I got no errors, no logs, it just simple runs with no problem, but nothing is printed.

ERROR: Partition key property must be provided

I created a graph db with Partition key value(it's required now). When I execute node app.js, it gives me error says:

Running Add Vertex1 Error:
Gremlin Query Execution Error: Add Vertex: Modify Data: Partition key property must be provided for creating a vertex on a partitioned collection.

NPM 5.6.0
Node 8.9.4
Windows 10

401 Response

bash-3.2$ node app.js
Running Drop
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: unexpected server response (401)
    at ClientRequest._req.on (/private/tmp/azure-cosmos-db-graph-nodejs-getting-started/node_modules/ws/lib/WebSocket.js:650:26)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:473:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)
    at TLSSocket.socketOnData (_http_client.js:362:20)
    at emitOne (events.js:96:13)
    at TLSSocket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at TLSSocket.Readable.push (_stream_readable.js:134:10)
bash-3.2$

I have double checked all settings in config.js

SASL auth error trying to connect

When running this app i get this error when trying to execute the "drop" command:

Access Denied: Gremlin websocket client failed to provide valid SASL authorization information that matches AuthorizedBackend configuration.

config.js:

config.endpoint = "******.graphs.azure.com";
config.primaryKey = "K.......=";
config.database = "graphdb"
config.collection = "graphcoll"

I copied the primaryKey straight from the Azure portal, under Keys -> Read-write Keys blade.

GraphMalformedException with array parameters.

When using array attributes, for example:

client
  .submit("g.V().has('value', within(arrayParameter))", {
    arrayParameter: []
  })

I get a malformed GraphSON error:

ActivityId : d3513f09-cf89-4d61-b2ac-31dbb60be085
ExceptionType : GraphMalformedException
ExceptionMessage :
        Gremlin Malformed Request: Unknown GraphSON type encountered: g:List. Path: 'args.bindings.anArray', Line: 1, Position: 215.
        GremlinRequestId : d3513f09-cf89-4d61-b2ac-31dbb60be085
        Context : graphcompute
        Scope : graphcomp-execquery
        GraphInterOpStatusCode : MalformedRequest
        HResult : 0x80131500

Had no trouble with the previous v2 client. Any idea if this is a problem with Azure, or the gremlin version?

Wildcard Vertex Property Searching

I am trying to migrate from AWS Titan to Azure Cosmos and I am 90% there with making the switch. The only blocker I have is that there appears to be support for wildcard search on properties.

Consider this query;

g.V().has("Category",textContains("Shoes"))

It appears textContains is not supported in Cosmos as I get the below error. Will this be provided in future or should I plan for never being able to do wildcard text searching?

Error
(1,91): error CS0103: The name `textContains' does not exist in the current context

Unexpected Server Response

C:\Users\<>\Desktop\graphAPI\azure-cosmos-db-graph-nodejs-getting-started>node app.js
Running Drop
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: unexpected server response (200)
    at ClientRequest._req.on (C:\Users\<>\Desktop\graphAPI\azure-cosmos-db-graph-nodejs-getting-started\node_modules\ws\lib\WebSocket.js:650:26)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:543:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:112:17)
    at TLSSocket.socketOnData (_http_client.js:440:20)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)

image

Is this a deprecation problem? How can I fix it?

Cannot create an edge using gremlin version 3.4

I tried creating an edge using
g.V(ids).addE('edgeRel').to(g.V(idt)) where ids and idt are the ids of the source and target vertex respectively. The edge is not created and the connection returns an undefined response. The vertices are created without any problem using the same connection.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.