Comments (6)
Hi,
Thank you for your feedback.
I see you are using 'options.populate' on the dataTable function but there is no populate option.
I added fields and models to the test (in test folder of this module) and the way you are building sensors field is not working with the actual implementation. If you use sub-document to do the same then it is working... I believe maybe there is a limitation in mongoose...
You can transform your model to achieve your needs:
var sensorSchema = new mongoose.Schema({
id: { type: String, unique: true },
description: String,
timeCreated: { type: Date, default: Date.now },
timeRegistered: { type: Date, default: Date.now }
});
mongoose.model('Sensor', sensorSchema);
var SensorSubDocSchema = new mongoose.Schema({
mac: { type: String, unique: true },
alias: { type: String, default: 'SENSOR' },
status: String,
type: { type: mongoose.Schema.Types.ObjectId, ref: 'Sensor' }
});
var controlunitSchema = new mongoose.Schema({
osver: String,
sensors: [ SensorSubDocSchema ]
});
mongoose.model('ControlUnit', sensorSchema);
/* Data fetch */
req.query.mDataProp_1 = 'types.type'
app.db.models.ControlUnit.dataTable(req.query, function (err, data) {
if (req.xhr) {
res.send(data);
}
});
Tell me if it works for you !
from mongoose-datatable.
Hi eherve,
thanks for reply. Unfortunately not work for me.
In your code: req.query.mDataProp_1 = 'types.type'
i've substitute with req.query.mDataProp_1 = 'sensors.type'
but with us i've only access to object type
ex: id, description and two date time but: mac, alias and status not exist.
Must I declare more field??
ex:
req.query.mDataProp_1 = 'sensors.type'
for get same data
req.query.mDataProp_2 = 'sensors'
for get another data
Thanks in advance
from mongoose-datatable.
Ref to docs at: mongoose populate it's possible add this feature by options? ex: options.populate? Should be very great!! 👍
from mongoose-datatable.
Hi,
The module load only what you are requesting nothing more. So you need to specify each data you want to fetch.
You need to add all the field you want in your request.
Regarding populate by option, you don't need it since the request of underlying fields will trigger the populate you need.
Regards,
from mongoose-datatable.
@lags have you find a solution to your issue? I'm facing a similar problem
from mongoose-datatable.
@eherve i'm having the same problem any solutions?
from mongoose-datatable.
Related Issues (20)
- Nested object search HOT 1
- mongoose-datatable-demo does not work with v1.0.4 HOT 2
- Column filtering/searching with regex HOT 8
- Nested object array search (Question) HOT 2
- Default Boolean handler not works for false value HOT 1
- Mongoose Queries HOT 10
- How to set conditions? HOT 1
- performance? HOT 1
- Unmanaged condition on field type: ObjectId HOT 3
- Can't get array data HOT 1
- Not working with __ttl document expiration via mongoose-ttl plugin HOT 2
- Date filtering HOT 5
- No data returned on mongoose 5 with options.conditions HOT 1
- search not working with populate data. HOT 1
- how to sort or order by date ('desc') HOT 1
- MongoDB uses non-optimal query indexes because of sort HOT 6
- Use aggregate with datatable HOT 1
- npm Installs Version 1.0.7 HOT 1
- Query lookup another collection, if not found still return HOT 1
- how to do subquery in formatter
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 mongoose-datatable.