Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Clone is not a function? #456

Open
SpyridonZ opened this issue Nov 18, 2021 · 1 comment
Open

Clone is not a function? #456

SpyridonZ opened this issue Nov 18, 2021 · 1 comment

Comments

@SpyridonZ
Copy link

Using basically a modified version of the example in the documentation at the "Dynamic Filter" section here: https://cult-of-coders.github.io/grapher/#Introduction

Regular queries are working, but if I attempt to use clone on any reusable queries, it's not working. Here's my code:

productQuery.js:

import {ProductCollection} from "../db/ProductCollection";

export default ProductCollection.createQuery(
    {
    $filter({filters, options, params}) {
        filters.code = params.code;
    },
    $options: {sort: {code: -1}},
    code: 1,
    price: 1,
    author: 1
});

Usage:

import { check } from 'meteor/check';
import { ProductCollection } from "../db/ProductCollection";
const { DateTime } = require("luxon");
import {Match} from 'meteor/check';
import productQuery from "./productQuery"; // Grapher query instance

Meteor.methods({

    'products.get'() {

        if (!this.userId) {
            throw new Meteor.Error('Access Denied: User not authenticated.');
        }

        // Example query
        return productQuery.clone({
            code: "0000"
        }).fetch()
    },

This results in:

I20211118-11:06:05.823(-8)? Exception while invoking method 'products.get' TypeError: productQuery.clone is not a function
I20211118-11:06:05.824(-8)?     at MethodInvocation.products.get (imports/api/productMethods.js:38:29)
I20211118-11:06:05.824(-8)?     at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1885:12)
I20211118-11:06:05.825(-8)?     at packages/ddp-server/livedata_server.js:769:19
I20211118-11:06:05.825(-8)?     at Meteor.EnvironmentVariable.EVp.withValue (packages\meteor.js:1257:12)
I20211118-11:06:05.826(-8)?     at packages/ddp-server/livedata_server.js:767:46
I20211118-11:06:05.826(-8)?     at Meteor.EnvironmentVariable.EVp.withValue (packages\meteor.js:1257:12)
I20211118-11:06:05.827(-8)?     at packages/ddp-server/livedata_server.js:765:46
I20211118-11:06:05.827(-8)?     at new Promise (<anonymous>)
I20211118-11:06:05.828(-8)?     at Session.method (packages/ddp-server/livedata_server.js:739:23)
I20211118-11:06:05.828(-8)?     at packages/ddp-server/livedata_server.js:603:43

Any ideas how to resolve this error? I tried searching and strangely I can't find anyone else who encountered this issue...

@vparpoil
Copy link
Contributor

Hi @SpyridonZ, you should provide a reproduction repository to get help on your issue. There is a big chance that this is the result of a misuse of the package.

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

No branches or pull requests

2 participants