Code Monkey home page Code Monkey logo

Comments (5)

ruohki avatar ruohki commented on June 14, 2024 2

These are not correct if you want to use parameters

from meteor-publish-composite.

timsun28 avatar timsun28 commented on June 14, 2024 1

For anyone who would like to use my code, feel free to use it as a start.
I'm not using this package any more in my projects and I don't have a lot of time right now to help out, but will check back later if there has been any progress on this.

from meteor-publish-composite.

StorytellerCZ avatar StorytellerCZ commented on June 14, 2024 1

Added this in v1.8.4, not perfect but a start.

from meteor-publish-composite.

timsun28 avatar timsun28 commented on June 14, 2024

Hi,
I'm trying to add my own types to this package as well, but I can't seem to get the find function working properly.
I've kept the following:

interface IOptions {
        find: <T = any>() => Mongo.Cursor<T>;
        children?: IOptions[];
        collectionName?: string;
}
function publishComposite(name: string, options: (this: Subscription, dataSpecs: any) => IOptions): void;

Where dataSpecs is my own parameter with the queries etc.

The function will return an IOptions with the find function that returns a Mongo.Cursor.

In my publication file I have the following example code:

publishComposite("myPublication", function (dataSpecs: any) {
    check(dataSpecs, Object);
    return {
        find() {
            const query: Mongo.Selector<MyCollection> = {
                ...dataSpecs.template.query,
                author: this.userId ?? "",
            };
            return Collection.find(query, dataSpecs.template.props);
        }
    }
});

Here I have the MyCollection as type for my collection and the Collection.find() returns a Mongo.Cursor<MyCollection, any>
But typescript returns the following error:
Type '<T = any>() => Cursor<MyCollection, any>' is not assignable to type '<T = any>() => Cursor<T, T>'.

Could anyone explain how this could be solved as I couldn't find a clear answer on the internet.

In case I get this solved, I will be happy to share my .d.ts file here and get it added to the package for others to use as well.

Thank you in advance!

from meteor-publish-composite.

StorytellerCZ avatar StorytellerCZ commented on June 14, 2024

PRs welcome!

from meteor-publish-composite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.