Closed StanleyAM closed 8 years ago
What is the output when running with the DEBUG=feathers-sync*
environment variable set?
Hi daffl,
Thanks your apply.
The log is like below:
feathers-sync will sync via adapter: mongodb +0ms
feathers-sync setting up database mongodb://XXXX.mlab.com +2ms
feathers-sync subscribing to handler localMemory created +51ms
feathers-sync subscribing to handler localMemory updated +1ms
feathers-sync subscribing to handler localMemory removed +1ms
feathers-sync subscribing to handler localMemory patched +0ms
feathers-sync emitting event to channel localMemory created +16s
feathers-sync emitting event to channel mongoDB created +172ms
feathers-sync got event, calling old emit localMemory created +3ms
Thanks.
Is that the whole log? It looks like it's only subscribing to localMemory
events. Can you try if
const feathers = require('feathers');
const bodyParser = require('body-parser');
const rest = require('feathers-rest');
const socketio = require('feathers-socketio');
const memory = require('feathers-memory');
const sync = require('feathers-sync');
const MongoClient = require('mongodb').MongoClient;
const service = require('feathers-mongodb');
MongoClient.connect('mongodb://XXXX.mlab.com').then(function(db){
const app = feathers();
app.configure(rest());
app.configure(socketio());
app.configure(sync({
db: 'mongodb://XXXX.mlab.com',
collection: 'events'
}));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use("localMemory", memory());
app.use('/mongoDB', service({
Model: db.collection('syncData')
}));
app.listen(8888);
});
Makes a difference?
Hi daffl,
Yes, it can work perfectly when configuring feathers' app in the callback of MongoClient's connection.
Thanks a lot.
I wonder why that is. But if it works that way we'll leave it for now.
Hi, the below is server side code:
When I create new data for both "mongoDB" and "localMemory", there are only "localMemory" firing the created event to client. But data actually is created at mongo database.
The client library uses 1) feathers-client v1.5.1, 2) socket-io v1.4.5 The server package version info is like below:
Thanks.
P.S. like #11. When I remove feathers-sync. The "mongoDB" real-time events works perfectly.