I would say do both. Allow a "handler" or submit events if there isn't one. 
Make a method on the main connection for modifying with an ID passed in 
(needed for when they didn't create it w/ your client) and make one in the 
returned object (though addNode would probably take a callback instead of 
returning) that doesn't require the ID.

Also, if you make a good one, claim your prize: 
http://gun.io/open/23/neo4j-nodejs-adapter

On Saturday, March 10, 2012 7:44:13 AM UTC-6, Oni wrote:
>
> Hi everyone,
>
> As an exercise to learn node.js, I propossed myself to write a module to 
> connect node.js with a Neo4j database.
> My problem is in how to design the module. 
>
> Neo4j is a graph database, so it basicaly has nodes and relationships 
> between nodes. Its interface is based on a RESTful protocol.
>
> These are issues are facing when writing the module:
>
>
>    - *Callbacks or to emit an event?*
>    
> The module should have access to operate over nodes and relationships. 
> These operations should be asynchronous. Should the operations recieve a 
> callback or emit an event? or both?
>
>    - *Operations on nodes*
>
> Let's say there is a operation to add a node like: 
>
>
> addNode(properties);
>
> Every node in the database has a unique id. When adding a new node to the 
> database returns a JSON with all the information about the operation 
> (including the id). Using the id, afterwards I could perform some modify 
> operations on the node. The database has a REST message to modify a node 
> and you have to indicate the identificator. 
> There is two options:
>
>    - The addNode operations returns in the callback or in the event the 
>    reponse from the database. So, the user could extract the id from this 
>    information and perform a modify(id,property,newvalue).
>    - The addNode operation returns a Node object. Then on this object you 
>    can perform operations like:
>
> var x = addNode(properties);
> x.modify(property, newvalue);
>
> Thanks in advance
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to