Git Product home page Git Product logo

capaj / moonridge Goto Github PK

View Code? Open in Web Editor NEW
66.0 7.0 8.0 6.65 MB

Mongo live query framework bootstrapped on socket.io-rpc and mongoosejs. Takes your mongoose models and allows for easy and elegant consumption over the network in your frontend app or in remote node process.

Home Page: http://capaj.github.io/Moonridge

License: MIT License

JavaScript 96.05% HTML 3.95%
mongoosejs realtime-database socket-io

moonridge's Issues

`npm test` fails because missing dependency `morgan`

After running npm test I get the following error.

npm test

> [email protected] test /Users/keheliya/dev/Moonridge
> mocha

  basic CRUD including working liveQueries
module.js:338
    throw err;
    ^
Error: Cannot find module 'morgan'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/keheliya/dev/Moonridge/test/e2e-smoketest/server.js:16:9)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

I think morgan is used by server.js

Updating records on a filtered result.

Open 2 browser tabs. Then on tab 1, filter the query to show only 1 result.
On the second tab update a record that does not exists in the first tab.
Sometimes the record updated on the second tab is shown on the first tab. But it shouldn't become visible because of the declared filter.
This problem should pose problems to pagination.

Maybe this problem is because the server treats both browser tabs as the same client?

add exists event

this event should be emitted whenever existence of doc changes from false to true.
So not only on creation, but also when server starts up.
Useful if you want to hook up cron job to a document or something like that.

Update with populated field

I just encountered an issue that I think turned out to be two different issues.

using this (partial) Schema
var MrQuotes = this.MR.model('Mrquotes', {
quote_number: Number,
quote_version: Number,
broker_id: { type: Schema.Types.ObjectId, ref: 'Brokers' },
mrClient_ids: [{type: Schema.Types.ObjectId, ref: 'Mrclients' }],
stat: String,
create_date: Date,....

I am able to retrieve records with all manner of queries against the model client side. No problems, in fact it works incredibly well. When I add a new object to the mrClient_ids array and call update that also works. However I found that if I sliced an item out of the array and called update the previous state was serialized to the database without the desired change. I tracked this down to mr-rpc-methods and compared toUpdate with doc after the _.merge(doc, toUpdate) and found that underscore was not merging the changes. I noticed that since I had been using populate that the objects looked very different and I guessed that lodash was probably getting confused. As you know the original document consists of the array of object ID's and not the fully populated document. So I tried an experiment. Before calling update I did a foreach on the collection, extracted just the _id's into an array, assigned them to the model and then ran the update. I actually expected this to work but it also didn't. I still don't know why. So I thought about replacing lodash for this, just to simplify things and used plain JS as described here: https://plainjs.com/javascript/utilities/merge-two-javascript-objects-19/

Using that technique I was then able to update both adding and removing objects. In either case I have retained the approach of updating the model with only the id's as that seems to be a cleaner solution rather than hoping that everything in between handles the nested objects correctly.

Any thoughts on this?

Thanks and by the way great work on this project. It's incredibly useful.

/W

Help in integrating with mean.js stack

Currently using the Yeoman https://github.com/meanjs/generator-meanjs to generate my app. A typical schema model.js looks like:

var mongoose = require('mongoose'),
  Schema = mongoose.Schema;

/**
 * Configuration Schema
 */
var ConfigurationSchema = new Schema({
    serialNumber: { type: String, trim: true}) },
    tz:           { type: String, trim: true, enum: ['EST','CST','MST','PST'] },
    user:         { type: Schema.ObjectId, ref: 'User' },
    updated_at:   { type: Date },
    created_at:   { type: Date, default: Date.now }
});

mongoose.model('Configuration', ConfigurationSchema);

ConfigurationSchema.pre('save', function(next){
  this.updated_at = Date.now;
  if ( !this.created_at ) {
    this.created_at = Date.now;
  }
  next();
});

Can you please explain how to translate this scaffolded system to using MR?

I don't quite see how to go from:

var ConfigurationSchema = new Schema({...});
mongoose.model('Configuration', ConfigurationSchema);

with controller:

exports.list = function(req, res) {
    Configuration.find({'user':req.user}).sort('-created').populate('user', 'displayName').exec(function(err, configurations) {
...
}

to

var configurationModel = MR.model('configuration', {...});

and controller.

Does the controller change, or can it use the Mongoose schema as before (for the existing routes)?

Simple example

Hi.
I am trying to merge your framework with a simple MEAN stack, but I never used jspm, so I'm a bit lost on the client side.
Using jspm install Moonridge=npm:moonridge-client i get

err  No version match found for github:rase-/node-XMLHttpRequest@a6b6f2

Can you provide a simple MEAN stack for your framework, or explain how to configure the client part?

Thanks

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.