I have 2 applications, one is simple node js app using moongoose and other is meteor js web app. The app with plain node js uses mongoose mode llike so:
var mongoose = require('mongoose')
const testSchema = new mongoose.Schema({
dummy: {
type: String,
required: true,
},
id: {
type: String,
required: true,
}
});
const Tests = mongoose.model('tests', testSchema);
module.exports = Tests;
And later i do
var test = new Tests();
test.dummy = "123";
test.save(function(err){
if(err)
console.log(err);
});
After that, i go to meteor app, i have a server collection which mapped directly like so:
import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
export const Tests = new Mongo.Collection ('tests');
Tests.schema = new SimpleSchema({
dummy: {
type: String,
required: true,
},
id: {
type: String,
required: true,
}
});
Tests.attachSchema(Tests.schema);
i can verify in command line mongo utlity with db.tests.find()
there are 2 records in that table. The database name is same in both apps, i checked that. So, i have server method in meteor js like this:
import { Tests } from "../collections/tests";
export const GetDummy = new ValidatedMethod({
name: 'GetDummy',
validate: new SimpleSchema({
my_id: { type: String },
}).validator(),
run({my_id}) {
var result = Tests.findOne({id: my_id});
var test = Tests.findOne();
test = Tests.find();
test = Tests.findOne({});
test = Tests.find({});
return result;
},
});
I call this server method from client, set a breakpoint on it and all test variables are undefined! However in the same time i tried to use this collection tests
with aldeed:tabular
and that plugin is able ot fetch data from that collection somehow. What can be wrong here?
Why does Tests.find() returns undefined, and aldeed:tabluar
fetches the data correctly? Why does meteor collection doesn’t map to mongoose created tests
?