englercj / kouch

A descriptive and powerful Object Data Mapper (ODM) for Couchbase.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

open to contributions?

bojand opened this issue · comments

Hello, just stumbled upon this repo... I've been playing around with a similar idea (mongoose inspired ODM for couchbase) for a little while, as I can and have time. It's not a separate repo and don't have anything published to NPM yet as I wanted something with a bit more complete before I published anything. You can find my work in this test repo under the lounge folder:

https://github.com/bojand/cbtest/tree/master/lounge

the design / api ideas are very similar. My lib has prefix (and suffix) support, hooks, virtuals, methods and statics, overriding toObject and toJSON with transform. I also have a few additional things in place. My prefix works a bit differently as it's an option set on the "key" field, but you get the idea I think. For example specifying which field is the document key, so that's handled automatically. and if not specified, then it uses _id.
Something like for example:

var siteSchema = new kouch.Schema({
          ip: { type: String, key: true, prefix: 'site:'},
          name: String,
          url: String
        });

it uses ip as the key for documents and prefixes site: to it when saves.
I also have in place index property on fields, which I envision would be used to automatically build views on those fields. For example something like:

UserSchema = new kouch.Schema({
    name: {
        first: String,
        last: String
    },
    email:    String,
   age:      { type: Number, min: 18, index: true }
}

For example in the future It would automatically build and create a view and make a function findByAge(...). This isn't implemented yet, but it was an idea.

I also just recently got refs working, at least for saving. a quick test can be seen in the main.js file, was just going to start writing some unit tests for this.

Anyway came up to this, so I thought if you were open to contributions I might as well try and contribute to this and get something solid. I do have a need for something like this for my work as we use node + couchbase, so it's definitely something I want to try and get somewhat working well, hopefully sooner rather than later. Please let me know if you're cool with contributions. I think I would start off with just some more tests perhaps as I have a fair amount of those done for schema / doc setup & options, And would familairize with soe specifics of the code. I stumbled upon a somewhat weird bug in mongoose when I was doing them that's been since addressed and it may be present in here too. Anyway let me know, i'll try and do a fork and put some tests in and do a PR.

Absolutely! That is why I am doing the development on GitHub. Please feel free to send any PRs over and I will get them in. Glad you found the repo!

I'm going to go ahead and start putting in some issues for what I would like to do next, that hopefully can give you some direction when you feel more comfortable.