Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    kurbsdude
    @kurbsdude
    any place to find basic a tutorial showing how to use this, something like a getting started tutorial?
    find a basic*
    Ben Fonarov
    @Chuwiey
    @kurbsdude we're working on it :) but the most basic functionality is adding it as an adapter and then using Model.adapter.query(cypher, {paramsobject})
    there's also the premade functions so you can Model.create and the like
    but right now that's lest supported
    since a graph orm is a bit different from an orm
    we're working on getting it to be more of a graph orm
    kurbsdude
    @kurbsdude

    Just a small question though, I am just starting with node and sails so please don't judge me :)

    So I wanted to recreate your create function in my user controller, because i need certain properties to be unique in the database (adding unique: true in user model is not working)... so in my UserController.js I made this custom function:

    create: function (req, res, next){
    
            var collectionName = ':user';
            var params = req.params.all();
            var paramsDB = '';
    
            User.parseOne(params, function (err, result){
               if (err) return next(err);
                paramsDB = result;
            });
    
            var q = [
                'CREATE (n' + collectionName + ' { ' + paramsDB + ' })',
                'RETURN n'
            ];
    
            User.query(q, params, function (err, user){
               if (err) return next(err);
                res.json(user);
            });
    
        }

    and in the sails-neo4j adapter.js file I added this at the end

    parseOne: function(params, cb){
            var parsedParams = parseOne(params);
            cb(null, parsedParams);
        }

    But this is giving me an error:

    TypeError: object is not a function
        at module.exports.parseOne ......... .... ...

    Any suggestions?

    kurbsdude
    @kurbsdude
    Never mind :D collectionName missing on parseOne:
    parseOne: function(collectionName, params, cb){
            var parsedParams = parseOne(params);
            cb(null, parsedParams);
        }
    kurbsdude
    @kurbsdude

    but

    User.query(q, params, function (err, user){
               if (err) return next(err);
                res.json(user);
            });

    still not working

    kurbsdude
    @kurbsdude
    I solved the above questions, however I am stuck at another big issue... Attributes set at the user models for validation like required:true are completely being ignored... Also when setting syncable: true in the adapter I get tons of errors
    Ben Fonarov
    @Chuwiey
    @kurbsdude hey there
    so in regards to query, keep in mind that if you're running that in the model, then you'll need to use User.adapter.query instead of User.query due to some weirdness with waterline and sails 0.9.16
    I don't know if you're using 0.10 though, and if you are, let me know and I'll need to look into it (but you'll probably still need to use User.adapter.query
    the second issue is that if you are returning res.json in the model, then the model has no understanding of what res is
    as for required:true and syncable:true - those aren't a great fit for a nosql db like neo4j. I can't tell you that required:true will work in the way you expect it to. But we'll have to consider how that might work...
    same with syncable: true
    also, if you have some ideas, please feel free to share and we might implement them, or ask for a pull request
    unique is different, it'll probably map to a neo4j constraint, but that means you'll get an error when trying to create something not unique, and will need to handle it
    any questions you have, feel free to ask, not a problem :)
    kurbsdude
    @kurbsdude

    To make this work with User.query, I changed your adapter.js file a little, I don't know if it is the right way of doing this
    I changed query: query to something like

    query: function(collectionName, q, params, cb){
            query(q, params, cb, true);
        },

    It would be great if attributes checks like the following could be used: (for example the following attributes work with other database adapters out there)

    attributes: {
         username: {
            type: "string",
              required: true,
          },
    
          name: {
            type: "string",
              required: true
          },
    
          password: {
            type: "string",
              required: true
          },
    
          email: {
            type: "string",
              email: true,
              required: true,
          }
      }

    For example while registering a user, it would be nice to have a required:true, giving errors for empty fields

    kurbsdude
    @kurbsdude

    or attributes could also have something like

    toJSON: function(){
             var obj = this.toObject();
              delete obj.password;
              return obj;
          }

    or

    beforeCreate: function(values, next) {
              //do something ();
      }
    kurbsdude
    @kurbsdude
    basically it would be nice to understand how to use validations shown in http://sailsjs.org/#!documentation/models for this adapter :)
    roackb2
    @roackb2
    are you guys still working on this project?
    and I just took a look at the adapter file and the whole file is so thin,
    is this project currently suitable for production usage or development only?
    would you please release a minimal viable README file to let us know
    what's the current situation of this project and how could I use it?
    Thanks a lot that someone is working on neo4j adapter and I know it's hard to
    get both development and documentation done both in short time,
    but I really need some basic understanding of
    how the relationship is mapped to sails' ORM
    and design my data modeling, hope you can give me some clues.
    Ben Fonarov
    @Chuwiey
    @roackb2 hey there, we are still working on it indeed... just trying to fit it in with all the other priorities... if you'd like, I can help you here directly, and we welcome any pull requests to help us out :)
    Arunram Kalaiselvan
    @arun057
    This message was deleted