[orientdb] Re: Adding edges with properties after using Document API
Well, with either approach you're actually using the Graph API once you start using the OrientGraph object. A Vertex (OrientVertex) is built on top of a document, and its ODocument can be obtained by calling vertex.getRecord(). But an ODocument is not a Vertex. By working with OrientVertex objects, you essentially get the best of both worlds. If you don't need the automatic management of links, then ODocument is just fine. -Colin Orient Technologies The Company behind OrientDB On Friday, March 6, 2015 at 5:04:43 AM UTC-6, Christian C wrote: > > Actually the better approach for me is to stick with the document api and > do like so: > > ODatabaseDocumentTx db = pool.acquire(); > OrientGraph g = new OrientGraph(db); > > > Out of interest is the a way to cast ODocument to Vertex and vice versa? > > > PS Would be nice if you could provide a one liner in the wiki for the > Document API and for the Graph API how to get the otherone. This my help new > commers a lot. > > -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[orientdb] Re: Adding edges with properties after using Document API
Actually the better approach for me is to stick with the document api and do like so: ODatabaseDocumentTx db = pool.acquire(); OrientGraph g = new OrientGraph(db); Out of interest is the a way to cast ODocument to Vertex and vice versa? PS Would be nice if you could provide a one liner in the wiki for the Document API and for the Graph API how to get the otherone. This my help new commers a lot. -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[orientdb] Re: Adding edges with properties after using Document API
Hey Christian, You can use the Document API via that call to getRawGraph() which returns an ODatabaseDocumentTx object. The Graph API, which implements the TinkerPop Blueprints interface, is also very easy to use and makes it simpler to add edges to vertices. Something to note about the Graph API v. the Document API. The Graph API by default operates within an automatic transaction because it has to maintain both sides of the operation when adding/managing links as edges. You can also called graphDB.command( ... ) to execute the SQL. But, if you're already using the Graph DB API, might as well just call addEdge on a vertex or on the graph DB object directly. Some of my document databases that I ported to OrientDB I just left as documents and manually added links to other documents. This gave me the graph functionality I needed, even though I was responsible for the connections instead of letting the database handle the edges. Hope that helps! -Colin Orient Technologies The Company behind OrientDB On Thursday, March 5, 2015 at 10:45:01 AM UTC-6, Christian C wrote: > > Thanks for the quick response Colin > > If I got you right, I can switch to the Graph API and use the Document API > functionality out of the Graph API right? Does this mean I can get > a ODatabaseDocumentTx via the Graph API also? This would be very great! > > But anyway I can always use the sql interface to create edges by calling: > > ODatabaseDocumentTx db = pool.acquire(); > db.command(new OCommandSQL("create edge Living from #10:3 to #11:4 > set from = '2000-01-01', to = '2012-04-06'")).execute(); > > Right? > > PS Thanks for helping me out, I am leaving from MongoDB because of the > Graph functionality so I was more "fimilar" to start of with the Document > API and now I do not want to rewrite things. > > -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[orientdb] Re: Adding edges with properties after using Document API
Thanks for the quick response Colin If I got you right, I can switch to the Graph API and use the Document API functionality out of the Graph API right? Does this mean I can get a ODatabaseDocumentTx via the Graph API also? This would be very great! But anyway I can always use the sql interface to create edges by calling: ODatabaseDocumentTx db = pool.acquire(); db.command(new OCommandSQL("create edge Living from #10:3 to #11:4 set from = '2000-01-01', to = '2012-04-06'")).execute(); Right? PS Thanks for helping me out, I am leaving from MongoDB because of the Graph functionality so I was more "fimilar" to start of with the Document API and now I do not want to rewrite things. -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[orientdb] Re: Adding edges with properties after using Document API
Hi Christian. If you want OrientDB to manage your links between the vertices, then yes, you'll need to use the Graph API to create edges and add them to the vertices. If you want to manage them yourself, then the Document API will work fine by maintaining the links yourself. Have you looked at the time-series example in the documentation? It might give you some ideas, if you haven't. http://www.orientechnologies.com/docs/last/orientdb.wiki/Time-series-use-case.html If you do switch to the Graph API, you can use the OrientGraphFactory, which includes pools. Once you have an OrientGraph object you can always call graph.getRawGraph() to gain access to the underlying document database. -Colin Orient Technologies The Company behind OrientDB On Thursday, March 5, 2015 at 8:49:30 AM UTC-6, Christian C wrote: > > I have used the Document API to insert all my Vertex (all classes are > extending V). Now I want to model relations ships with a valid period of > time. Lets say "Person" -> is living {from : 2000-01-01, to : 2012-04-06} > -> London. What is the right option for me to add such a relationship > (edge). I am using OPartitionedDatabasePoolFactory right now. But I have no > Idea how to add Edges. Do I have to swicht to graph API? And if so how can > I do this - I mean reopening another connection pool is not the best option > right? > -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.