Comments (5)
These are not correct if you want to use parameters
from meteor-publish-composite.
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.
Added this in v1.8.4, not perfect but a start.
from meteor-publish-composite.
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.
PRs welcome!
from meteor-publish-composite.
Related Issues (20)
- Published version on atmosphere includes `eslint` (increases package size by at least 16MB) HOT 2
- Empty children HOT 4
- Publish loses reactivity after "load more" HOT 4
- Move to Meteor-Community-Packages organization? HOT 1
- All published records removed and re-added on subsequent subscriptions in 1.7.1 HOT 4
- Error: Doc not found in list HOT 1
- Join Data from Array of ID's HOT 1
- Exception in callback of async function: TypeError: Converting circular structure to JSON HOT 2
- [Question] How to use it together with middleware ? HOT 1
- Full compatibility with johanbrook:publication-collector
- children function won't rerun reactively
- Meteor collection hook direct not working
- Unset fields are not unset HOT 3
- Add TypeScript types HOT 1
- Remove underscore HOT 16
- Create GitHub action to run tests HOT 3
- Publications are ready before object merges are complete since 1.8.2 HOT 11
- Unhandled promise rejection HOT 3
- Error: Doc not found in list HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-publish-composite.