Re: [orientdb] Re: How to store JSON - as object or string?

2015-06-29 Thread Joao Barcia
Thanks guys. We are mostly using studio for our db input for the moment.
After a few tests it seems that creating an embedded set property in our
lesson class worked perfectly.

Below is an example of what we put inside of it. It is also being loaded
nicely as a JSON object from our client side in meteor

Let me know if there is any reason why this is incorrect/bad practice.

Cheers

[
 {
 type: exerciseString,
 question: What is blah blah?,
 answers: [
 answer 1 string,
 answer 2 string,
 answer 3 string
 ]
 },

 {
 type: explanation,
 contents: [
 {
 text: Welcome to this unit with text and stuff
 },
 {
 img: /images/mathsImg.jpg
 },
 {
 text: Go forward and learn more amazing things
 }
 ]
 }
 ]




On 29 June 2015 at 08:34, alessandrorot...@gmail.com wrote:

 Hi Joao,
 this is an example of code for Embedded List from java api

 OrientGraph g=new OrientGraph(currentPath);

 OClass cl=g.createVertexType(Person, V);
 cl.createProperty(name, OType.STRING);
 cl.createProperty(lista, OType.EMBEDDEDLIST);
 ListAuto lista1=new ArrayListAuto();
 lista1.add(new Auto(Ferrari));
 lista1.add(new Auto(Lamborghini));
 Gson gson = new Gson();
 String json = gson.toJson(lista1);
 OrientVertex v1=g.addVertex(class:Person);
 v1.setProperties(name,alessandro);
 v1.setProperties(lista,json);

 g.shutdown();

 Regards,
 Alessandro

 --

 ---
 You received this message because you are subscribed to a topic in the
 Google Groups OrientDB group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/orient-database/7a3uLdLn7KY/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 orient-database+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 

--- 
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: How to store JSON - as object or string?

2015-06-29 Thread alessandrorota04
Hi Joao,
this is an example of code for Embedded List from java api

OrientGraph g=new OrientGraph(currentPath);

OClass cl=g.createVertexType(Person, V);
cl.createProperty(name, OType.STRING);
cl.createProperty(lista, OType.EMBEDDEDLIST);
ListAuto lista1=new ArrayListAuto();
lista1.add(new Auto(Ferrari));
lista1.add(new Auto(Lamborghini));
Gson gson = new Gson();
String json = gson.toJson(lista1);
OrientVertex v1=g.addVertex(class:Person);
v1.setProperties(name,alessandro);
v1.setProperties(lista,json);

g.shutdown();

Regards,
Alessandro

-- 

--- 
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.