Coder Social home page Coder Social logo

doqmentdb's People

Contributors

a8m avatar apeteshis avatar atinylittleshell avatar bryant1410 avatar gitter-badger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

doqmentdb's Issues

Support paging for find function in manager.js

The current manager.js find function always call toArray which enumerate all the results and can make fill up the memory or cause throttling, you may need to support using queryIterator.executeNext and support paging based on it to solve this issue.
You can look at queryIterator test in documentdb for a sample of executeNext

Entity tag

use the resource _etag to manage concurrency control locally.

Schema with Array of Objects

How do we specify an array of embedded documents in the schema?

Eg: In MongooseJS I'd specify as

var BlogSchema = new Schema({
    title: String,
    body: String,
    comments: [{
        commenter_id: String,
        comment: String
    }]
});

How do we embed the comments schema in blog schema in doqmentdb?

Unhandled rejection Error when creating a new object

When i try to create a new user like this:

users.create({ name: req.body.name, email: req.body.email, password: req.body.password})
.then(console.log)
.catch(console.log);

I only get an unhandled rejection error. Screenshot of the Error attached.
error

Add request options

Add the ability to add custom headers, e.g: maxItemCount, continuation, etc..

collection schema

e.g:

var schema = {
  name: {
    type: String,
    fixture: 'foobar'
    regex: /^[a-zA-Z]{3,}$/
  }, 
  phone: {
    type: Number,
    regex: test() // could be a function 
  },
  isAdmin: {
    type: Boolean,
    fixture: false
  },
  // ...
};

users.use(schema);
user.create({ name: 3245 })
  .catch(console.log); // → Error: name must be type string, and least 3 chars

user.create({ name: 'Ariel', phone: 777, foo: 'bar' })
  .then(console.log); 
  // schema will omit the `foo` field 
  // { name: 'Ariel', phone: 777, isAdmin: true, id: '8...31', _self: ... }

update 25.12:
what about expose field?(e.g: password)

[example]: middleware and schema

create example app that show middleware ability, with createdAt, updatedAt, passwordencryption, etc..
and schema unexposing fields, etc..

Add custom UDF´s

How can I extend the set of UDF´s provided (like $in, $exists and so on) by writing one by myself?

"Unhandled rejection Error: invalid operator" throwing in query/index.js:46:22

I'm trying out doqmentdb but I see this error being thrown all the time. I was testing if it can handle sending 50+ requests to DocumentDB every 500ms using setInterval, but this error is thrown multiple times, even though it seems like most of the operations complete successfully. Even if I try inserting one record every 500ms, this error is thrown at least once(but then again it seems all requests complete successfully).

Here is all the code that I'm running:

var Doqment = require('doqmentdb')
var host = 'xxxxx'
var masterKey = 'xxxxx'
var connection = new (require('documentdb').DocumentClient)(host, {masterKey: masterKey})

var db = new Doqment(connection, 'test')
var users = db.use('users')

/**
* Model definition
*/

var model = {
    name: {
        type: String,
        default: ''
    }
}

users.schema(model)

users.pre('save', function(next) {
    this.createdAt = new Date().toString()
    next()
})

var errors = 0, successes = 0

function createUser(index) {
    users
        .create({ name: 'agon' })
        .then(function(data) {
            console.log('Created user:', data.id)
            successes += 1
        })
        .catch(function() {
            console.log('Error at i=%d', index)
            errors += 1
        })
}

var createUsers = setInterval(function() {
    for(var i = 0; i < 50; i += 1) {
        createUser(i)
    }
}, 500)

setTimeout(function() {
    clearInterval(createUsers)
    console.log('Success: %d', successes)
    console.log('Errors: %d', errors)
}, 5000)

And this is the trace log of the error:

Unhandled rejection Error: invalid operator
    at Error (<anonymous>)
    at /home/agonbina/Playground/doqmentdb-test/node_modules/doqmentdb/lib/query/index.js:46:22
    at Array.map (native)
    at query (/home/agonbina/Playground/doqmentdb-test/node_modules/doqmentdb/lib/query/index.js:26:27)
    at module.exports (/home/agonbina/Playground/doqmentdb-test/node_modules/doqmentdb/lib/query/index.js:80:36)
    at Manager.findOrCreate (/home/agonbina/Playground/doqmentdb-test/node_modules/doqmentdb/lib/manager.js:40:17)
    at /home/agonbina/Playground/doqmentdb-test/node_modules/doqmentdb/lib/collection.js:428:15
    at /home/agonbina/Playground/doqmentdb-test/node_modules/doqmentdb/node_modules/bluebird/js/main/using.js:165:30
    at tryCatcher (/home/agonbina/Playground/doqmentdb-test/node_modules/doqmentdb/node_modules/bluebird/js/main/util.js:24:31)
    at Promise._settlePromiseFromHandler (/home/agonbina/Playground/doqmentdb-test/node_modules/doqmentdb/node_modules/bluebird/js/main/promise.js:454:31)
    at Promise._settlePromiseAt (/home/agonbina/Playground/doqmentdb-test/node_modules/doqmentdb/node_modules/bluebird/js/main/promise.js:530:18)
    at Promise._settlePromises (/home/agonbina/Playground/doqmentdb-test/node_modules/doqmentdb/node_modules/bluebird/js/main/promise.js:646:14)
    at Async._drainQueue (/home/agonbina/Playground/doqmentdb-test/node_modules/doqmentdb/node_modules/bluebird/js/main/async.js:175:16)
    at Async._drainQueues (/home/agonbina/Playground/doqmentdb-test/node_modules/doqmentdb/node_modules/bluebird/js/main/async.js:185:10)
    at Async.drainQueues (/home/agonbina/Playground/doqmentdb-test/node_modules/doqmentdb/node_modules/bluebird/js/main/async.js:15:14)
    at process._tickCallback (node.js:442:13)

Support `$` operations

e.g:

users.update({ ... }, { array: { $push: 1 } });
users.update({ ... }, { array: { $concat: [2] } });
// $pop, $shift, $unshift, ...
// $map ?, $filter ?

Schema that contains other schema type

How do I model relationships with doqmentDB? Like say I have Players and Clubs, how do I specify that Club has many Players and a player belongs to a Club? How do I add limit and sort to queries?

Unhandled rejection error

I just started looking into this package and I'm trying to run the examples(in this repo) but getting the following error with each of them.

Anyone any clue what I'm missing?

Unhandled rejection Error: [object Object]
at Object.ensureErrorObject (F:\Github\doqmentdb\node_modules\bluebird\js\main\util.js:261:20)
at Promise._rejectCallback (F:\Github\doqmentdb\node_modules\bluebird\js\main\promise.js:469:22)
at Promise._settlePromiseFromHandler (F:\Github\doqmentdb\node_modules\bluebird\js\main\promise.js:513:17)
at Promise._settlePromiseAt (F:\Github\doqmentdb\node_modules\bluebird\js\main\promise.js:581:18)
at Promise._settlePromiseAtPostResolution (F:\Github\doqmentdb\node_modules\bluebird\js\main\promise.js:245:10)
at Async._drainQueue (F:\Github\doqmentdb\node_modules\bluebird\js\main\async.js:128:12)
at Async._drainQueues (F:\Github\doqmentdb\node_modules\bluebird\js\main\async.js:133:10)
at Immediate.Async.drainQueues as _onImmediate
at processImmediate as _immediateCallback

Atomic Transactions

  • switching things to sporcs and triggers(for hooks)
  • prefix this methods with $ sign

updateOne

create aliases updateOne to findOneAndModify (same as update and findAndModify )
update: also for sporcs

Inconsistent usage of this.database

I'm using doqmentdb 0.2.3. When you create a DoQmentDB object, you pass it the database name you want to use. The value is stored in this.db. Then, when you get a Collection object using db.use('someCollection'), the value of this.db is passed to Collection constructor. Nothing weird so far.

Everything is fine as long as this.db is the string I originally passed to DoQmentDB constructor. But in some cases, this.db in DoQmentDB is replaced by a database object and if I get new collection managers via db.use(), all hell breaks loose. The Collection constructor is now passed an object instead of a string, which is bad. The object is passed to manager.findOrCreate() (line 291 of collection.js) and all the way to query() in lib/query.js. When this happens, the "invalid operator" error gets thrown from line 46.

The error occurs at least when I search for collections using db.find() and wait for the promise to resolve (which I guess is also the point where this.db gets overridden internally) and then get a new collection object. A very simple piece of code to reproduce the issue:

    db.find().then(function(results) {
        var collection = db.use('some_collection');
        collection.find();
    });

find operation

The queryBuilder should limit AND operators to 5(i.e: 6 keys).
DocumentDB throw an error:
"The SQL query exceeded the maximum number of 'AND' operators. The allowed limit is 5"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.