-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change collection.** strange callback arguments #3
Comments
I get derby-examples/directory app and try to apply store.hook('create', 'people', .... But where can I get store? ---- sever.js ---- require('derby-starter').run(__dirname, {port: 8004}); |
Derby-starter doesn't provide API to get |
Ok, done. Here server.js var async = require('async');
var derby = require('derby');
var http = require('http');
var chalk = require('chalk');
var publicDir = process.cwd() + '/public';
derby.run(function(){
require('coffee-script/register');
require('./server/config');
var apps = [
require('./apps/app')
// <end of app list> - don't remove this comment
];
var express = require('./server/express');
var store = require('./server/store')(derby, publicDir);
var error = require('./server/error');
express(store, apps, error, publicDir, function(expressApp, upgrade){
var server = http.createServer(expressApp);
server.on('upgrade', upgrade);
async.each(apps, bundleApp, function(){
server.listen(process.env.PORT, function() {
console.log('%d listening. Go to: http://localhost:%d/',
process.pid, process.env.PORT);
});
});
function bundleApp (app, cb) {
app.writeScripts(store, publicDir, {extensions: ['.coffee']}, function(err){
if (err) {
console.log("Bundle don't created:", chalk.red(app.name), ', error:', err);
} else {
console.log('Bundle created:', chalk.blue(app.name));
}
cb();
});
}
});
}); Here I see store, how do you propose use it? module.exports = function(store) {
require('derby-hook')(store);
store.hook('create', 'people', function(docId, value, session, backend) {
model = store.createModel();
model.fetch ('people.'+docId, function(err){
model.set('people.'+docId+'.uuid', 'HERE-MY-UUID-FOR-EXAMPLE');
})
});
} and try to use store in server.js ...
var store = require('./server/store')(derby, publicDir);
require('./hook')(store); // <---------- Is it right?
... It's Ok? |
I think it's OK. We use it the way. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
If I call the change hook like this
the arguments returned to the callback function are wrong. docId is assigned with the OT and I cant get the docId.
I used this workaround
The text was updated successfully, but these errors were encountered: