Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Bug] Pass collection name in join function doesn't work #24

Open
diavrank opened this issue Jun 24, 2020 · 0 comments
Open

[Bug] Pass collection name in join function doesn't work #24

diavrank opened this issue Jun 24, 2020 · 0 comments

Comments

@diavrank
Copy link

Hi, I tried to use <Collection>.join("CollectionName",....) but it seems that it doesn't work. Only works if I inject the object collection.

Summary:

This works:

TripsPubs.js in server side

import {Trip} from "./Trip";
import {PermissionMiddleware} from "../../middlewares/PermissionMiddleware";
import Permissions from "../../startup/server/Permissions";
import {Vehicle} from "../Vehicle/Vehicle";

const tripsPublication = new PublishEndpoint('trips', function () {
    Trip.join(Vehicle,"idVehicle","vehicle",["brand"]);
    let cursor=Trip.find();
    console.log("trip: ",cursor.fetch());
    return Trip.publishJoinedCursors(cursor,{ reactive: true }, this);
});

tripsPublication.use(new PermissionMiddleware([Permissions.TRIPS.LIST]));

ListTrips.vue in client side

 meteor: {
            $subscribe: {
                trips: []
            },
            trips() {
                Trip.join(Vehicle,"idVehicle","vehicle",["brand"]);
                console.log("Trips: ", Trip.find().fetch());
            }
        }

With collection name doesn't work

TripsPubs.js in server side

import {Trip} from "./Trip";
import {PermissionMiddleware} from "../../middlewares/PermissionMiddleware";
import Permissions from "../../startup/server/Permissions";

const tripsPublication = new PublishEndpoint('trips', function () {
    Trip.join("vehicles","idVehicle","vehicle",["brand"]);
    let cursor=Trip.find();
    console.log("trip: ",cursor.fetch());
    return Trip.publishJoinedCursors(cursor,{ reactive: true }, this);
});

tripsPublication.use(new PermissionMiddleware([Permissions.TRIPS.LIST]));

ListTrips.vue in client side

 meteor: {
            $subscribe: {
                trips: []
            },
            trips() {
                Trip.join("vehicles","idVehicle","vehicle",["brand"]);
                console.log("Trips: ", Trip.find().fetch());
            }
        }

Tested on Meteor 1.10.2
I had to add underscore package using meteor add underscore

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant