I have a collection named LibraryItems
which is available on both client and server side.
api/libraryitems/libraryitems.js
import { Mongo } from 'meteor/mongo';
const LibraryItems = new Mongo.Collection('libraryitems');
export default LibraryItems;
Instead of an if (Meteor.isServer) {..}
publication in this same file, I would like to have a server folder with the specific publications:
api/libraryitems/server/publications.js
import LibraryItems from '../libraryitems';
import { Meteor } from 'meteor/meteor';
Meteor.publish('LibraryItems.pub.all', function () {
return LibraryItems.find({});
});
But somehow, against my expectations, this publication is not available...
update
This is my subscription code (meteor+reactjs): ./imports/ui/Library.js
import LibraryItems from '../api/libraryitems/libraryitems';
import { createContainer } from 'meteor/react-meteor-data';
...
export default createContainer(() => {
Meteor.subscribe('LibraryItems.pub.all');
var libraryitems = LibraryItems.find().fetch();
return {
libraryitems: libraryitems
}
}, Library);
I forgot to register the publications in mains.js
:
import '../imports/api/libraryitems/server/publications';