Comments (10)
Yes, you can check here: https://github.com/moleculerjs/moleculer-examples/blob/master/conduit/services/articles.service.js#L45
Here the favorited
is just a virtual field but it calls other services to collect the data.
from moleculer-db.
Thank you!
How would I go about populating the virtual field? I did try this:
messages(ids, conversations, rule, ctx) {
return this.Promise.all(conversations.map(conversation => ctx.call("messages.has", { conversation: conversation._id.toString() }).then(res => conversation.messages = res)));
},
has: {
params: {
conversation: { type: "string" }
},
handler(ctx) {
let params = {
sort: ["createdAt"],
populate: ["author"],
query: { conversation: ctx.params.conversation }
};
return this.adapter.find(params);
}
},
Although it just returns the non populated data.
from moleculer-db.
Ahh I forgot to transform the result return this.adapter.find(params).then(doc => this.transformDocuments(ctx, params, doc));
from moleculer-db.
Do you know why a service wouldn't generate new data on a request? I made a request to get a conversation and then another to get a different one although the response was the same. Looking at the metrics the second request it doesn't call all services and some are in yellow and have a *
net to it where as the first request didn't.
from moleculer-db.
it means, the response comes from the cache. If you got the same result for different request means, you should fine-tune the cache key fields. More info: http://moleculer.services/docs/0.13/caching.html#Cache-keys
from moleculer-db.
I don't have caching fields added. So it shouldn't cache, I purposely removed them for development.
from moleculer-db.
But the yellow *
means the response came from cache
from moleculer-db.
It turns out I had this in my config which was the problem:
cacher: {
type: "memory",
options: {
maxParamsLength: 100
}
},
The weird thing is that it wasn't caching everything and as I said I removed the cache fields so is that strange behaviour?
Just in case you're wondering I'm working on a chat application :) video here I made it with VueJS and VueX, it's an SPA too.
from moleculer-db.
Yes, this config enable caching, and moleculer-db base query actions have enabled caching by default. But if you extend it with custom actions they won't be cached by default, just if you set it.
Nice project. Is it a private or public project?
I started a kanban project with the same tech stack :). But I stuck in the authentications :(
from moleculer-db.
It's a private project for now, nothing to say it won't become public though!
from moleculer-db.
Related Issues (20)
- I can't query or in SQL SERVER. Please help me
- "server instance pool was destroyed" in a persistence service with mongo when mongo db restarts HOT 2
- issue with #235 HOT 4
- How to use mongoose transaction in moleculer-db-adapter-mongoose? HOT 1
- sequelize adapter: Returns an object with undefined _id if idField is not explicitly set HOT 1
- [Mongoose V7] : Connection.prototype.close() no longer accepts a callback HOT 2
- [SECURITY] automatically created molecular-db actions can't be authenticated HOT 3
- Virtuals with reference are not populated when using mongoose adapter HOT 1
- Bluebird library for promise management shouldn't be used anymore HOT 1
- Wrong SequelizeDbAdapter constructor argument type HOT 1
- Sequelize: What is the value of counting DISTINCT on a primary key? HOT 5
- Potential error in updateById and Mongoose adapter HOT 1
- [Mongoose adapter] Error in the log when starting two or more services HOT 4
- How to make upsert operation with moleculer db? HOT 1
- Redundant code HOT 1
- Irrelevant fields are not removed during creation HOT 1
- Custom Sequelize Datataype HOT 1
- Case insensitive search [moleculer-db-adapter-sequelize] HOT 1
- how to rewrite actions like insert/update HOT 1
- mongoose adapter trouble with connect HOT 15
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 moleculer-db.