grapher
grapher copied to clipboard
Clone is not a function?
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...
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.