Re: [orientdb] Digest for orient-database@googlegroups.com - 1 update in 1 topic

13 views
Skip to first unread message

André Toscano

unread,
Jan 15, 2018, 11:36:44 AM1/15/18
to orient-...@googlegroups.com
For the "#-2:0" try to change your query to:

select @rid.asString() as rid, Type, Name from Attractions

I don't know your background but you are asking information about the object class (getClass).  This is very useful when you need to know what is the object that you are dealing in order to find it specification in the documentation. (Example: http://orientdb.com/javadoc/2.2.x/com/orientechnologies/orient/core/record/impl/ODocument.html). If print(...) something, it will be printed in the log files. Take a look at the example of the log below:

root@odb-node1:~# tail -f /orientdb/log/orientdb.log 

TAGS: starting processing...

=====================================

Total Entities to process: 510957

Total Relationships to process: 537349

Total objects to process: 1048306

==================================

class com.orientechnologies.orient.core.record.impl.ODocument

class com.orientechnologies.orient.core.record.impl.ODocument

class com.orientechnologies.orient.core.db.record.OTrackedMap

 
I recommend you to spend some time looking at how functions should be created in OrientDB: http://pizzaconnections.net/2015/04/02/orientdb-functions-by-samples-1/
And, also take a look at the list below, I've selected some samples that you can adapt and use as you want:

var db = orient.getDatabase();
res = db.command('select @rid.asString() as rid,@class.asString as type,data, metadata, location from Companies skip 0 limit 100');
return res.toString();

====

print('=====================================');
print('TAGS: starting processing...');
print('=====================================');

//info = com.orientechnologies.common.log.OLogManager.instance().info;

// Accessing the database/graph
var db = orient.getDatabase();
var mydb = orient.getGraph();

//var result=mydb.getVerticesOfClass('Localidades_brasileiras');
var qres = db.command('select count(*) from Entity');
var countEntity = qres[0].field('count');
print('Total Entities to process: '+countEntity.toString());

var qres = db.command('select count(*) from Relationship');
var countRelationship = qres[0].field('count');
print('Total Relationships to process: '+countRelationship.toString());

print('Total objects to process: '+(countEntity+countRelationship).toString());
var result = db.command('select @rid,metadata,ts from Company limit 10');
if(result!=null){
  
  for(i=0;i<result.length;i++){
        print('==================================');
        res = result[i];
        print(res.getClass());
        metadata = res.field('metadata');
        print(res.getClass());
        print(metadata.getClass());
        tags = metadata.get('tags');
        print(tags);
        break;
  }
}
return 'Cool'; 

====

Hope this help you.
Regards

André Emilio Toscano


2018-01-15 6:28 GMT-02:00 <orient-...@googlegroups.com>:
"Ashwini. Kumar" <ashwin...@gmail.com>: Jan 14 03:37PM -0800

Hi,
I created a function like this
 
----
def attractions = orient.getDatabase().query("select @rid, Type, Name from
Attractions");
return attractions.getClass();
----
 
All I was expecting to get back was rid, type and Name. Instead I am
getting a lot of other attributes like @version , @type, @rid, @fieldTypes.
 
 
Also, this @rid attribute seems wrong. It starts with a negative number
("#-2:0")
 
These additional unwanted attributes are complicating my middleware and
frontend. Can we just suppress them at the funtion level?
 
thanks,
Ashwini
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to orient-database+unsubscribe@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages