I used Meteor + Mongoose
, I tried to real-time data with meteor pub/sub. it’s work on local
, but when deploy project to server
it’s not work(get data) when insert update
and remove
.
Mongoose config connection :
import Mongoose from 'mongoose'
run().catch(err => console.log(err));
async function run() {
// for local
const HOST = 'localhost'
// const HOST = 'mongodb' for deploy to server
const PORT = 27017
const DB_NAME = 'dbName'
await Mongoose.connect(`mongodb://${HOST}:${PORT}/${DB_NAME}`, {
useNewUrlParser: true,
useCreateIndex: true,
useUnifiedTopology: true,
});
}
Config meteor pub on server side :
import { Meteor } from 'meteor/meteor'
import Collection from 'path'
Meteor.publish('getDataRealTime', selector => {
// Meteor._sleepForMs(100);
return Collection.find(selector)
})
meteor subscribe on client side I use vue-mixin:
import Collection from 'path'
export default {
meteor: {
$subscribe: {
'getDataRealTime': function () {return []},
},
realTimeData() {
let data = Collection.find(selector).fetch()
return data
},
},
}
can you help me ?