Git Product home page Git Product logo

forestadmin / forest-express-mongoose Goto Github PK

View Code? Open in Web Editor NEW
193.0 11.0 28.0 4.94 MB

🌱 ExpressJS/Mongoose agent for Forest Admin to integrate directly to your existing ExpressJS/Mongoose backend application.

Home Page: https://www.forestadmin.com

License: GNU General Public License v3.0

JavaScript 99.95% Shell 0.05%
admin expressjs mongoose package nodejs javascript admin-panel internal-tool backend backend-api

forest-express-mongoose's People

Contributors

adriguy avatar arnaud-moncel avatar arnaudbesnier avatar arnaudvalensi avatar closingin avatar daytf avatar dependabot-preview[bot] avatar dependabot[bot] avatar drraider avatar forest-bot avatar ghusse avatar guillaumecisco avatar jeffladiray avatar larcin avatar louisclisson avatar lucasscariot avatar marcperrinp avatar olesyakorovina avatar rap2hpoutre avatar realspok avatar romain-gilliotte avatar romaincoudour avatar root-io avatar scra3 avatar seyz avatar shohanrahman avatar slimee avatar stevebunlon avatar thenkei avatar vincentmolinie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

forest-express-mongoose's Issues

How to ignore Babel build artifacts ?

My build will output javascript source map files using Babel. The init function from forest-express-mongoose will try to load these files as they are co-located with other model files after the build. The init function then fails.

Is there a way to ignore certain files or file patterns during this initialization process ?

Cannot change the default route path

Hello,
I would like to move the default route path to /api/forest.
In my forest admin interface i change the default endpoint to end with /api
then in my app.js i initialize forest like this :

app.use('/api', require('forest-express-mongoose').init({
    modelsDir: __dirname + '/models',  // Your models directory.
    envSecret: config.forest.env_secret,
    authSecret: config.jwt.secret,
    mongoose: mongoose // The database connection.
}));

But then the password doesn't work and i have that in my log : [forest] 🌳🌳🌳 Bad JWT token.
And indeed when i console.log req.user i can see that it's undefined.

Mongoose middleware not called

Expected behavior

Was trying to do some logic after save/update operation, say cascade delete/update

Actual behavior

Mongoose middleware was not called when update/save.

const schema = new Schema({...}) schema.pre('save', function(next) { // do stuff next(); });

  • Package Version: 2.14.1
  • Express Version: 4.16.3
  • Mongoose Version: 5.2.8
  • MongoDB Version: latest

Am I doing it the wrong way or is there other way to do cascade logic?

Liana fails when fields are not selected by default

Expected behavior

We deselect certain fields by default in some of our models. An example would be the password field in the user object.

When we see the object, we should be allowed to modify only the fields that we change.

Actual behavior

The Liana refuses to save since the field is a required field. Further even if I add a value it fails some of our validation checks.

Failure Logs

[forest] 🌳🌳🌳  Cannot update the User #5ab186465f76210fd6f278d3 because of an unexpected issue: ValidationError: password: Cannot read property 'isProfileCompleted' of null

Context

TODO: Please provide any relevant information about your setup.

  • Package Version: ^2.14.2
  • Express Version: ^4.15.4
  • Mongoose Version: ^5.2.13
  • MongoDB Version: 3.6

Collection not found after error message is returned via extended Admin API

Was trying to do some business logic when deleting a document via the extended Admin API. When I returned an error message to forest, the intended-to-be-deleted document cannot be viewed. It can only be viewed after the page is refreshed. Am I doing it the wrong way?

Expected behavior

Able to click and view the detail of the selected document even after error message is return via the extended Admin API.

forestAdminApiRouter.route('/Group/:id').delete(async (req, res, next) => { try { res.status(400).send('This is the error message'); } catch (err) { res.status(400).send(err.message); }

Actual behavior

Returns 404 collection not found with error message "The collection you are trying to reach no longer exists, it may have been renamed"

Context

  • Package Version: 2.14.1
  • Express Version: latest
  • Mongoose Version: 5.2.8
  • MongoDB Version: latest

Once again impossible to use forest-express-mongoose in ES5 environment

This is not per-se your fault but this shows why it's dangerous to use "fuzzy" npm package versions when it comes to using NodeJS in PRODUCTION.

forest-express-mongoose 2.2.25 depends on forest-express "^0.1.33" which currently resolves to 0.1.33
forest-express 0.1.33 depends on jsonwebtoken "^7.1.9" which currently resolves to 7.2.0
jsonwebtoken 7.2.0 depends on joi ^10.0.1 which currently resolves to 10.0.5
joi 10.0.5 breaks on ES5 because of :
const Hoek = require('hoek'); https://github.com/hapijs/joi/blob/master/lib/index.js#L5

All that because of stupid merge request in jsonwebtoken which warns them of failure on old node env :
https://travis-ci.org/auth0/node-jsonwebtoken/builds/179471404

Linking forest explicitly to jsonwebtoken version 7.1.9 will fix this until they fix their mistake.

Until then, we are back to square one being unable to use forest with ES5.

Edit : here is my comment for the jsonwebtoken team auth0/node-jsonwebtoken@99127ee#commitcomment-20103622

Express/mongoose hasmany issue / doc missing

Expected behavior

Display hasmany in Related Data of a document.

##Β Actual behavior

I have a users collection and a booking collection. In a booking, there is a ref to a user but no ref of the booking in the user. I would like to access the bookings of a specific user.

Liana.collection('Users', { fields: [ { field: 'bookings', type: 'String', reference: 'bookings.id' } ] })

I tried to adapt the exemple of the doc at my case but no way, I can't get the Bookings of the user.

If I use reference I get an error (not an issue because there isn't any ref in the user) but the documentation has just this exemple. I don't really know if it's a bug / a missing feature or a lack of documentation.

  • Package Version: 2.13.1
  • Express Version: 4.15.4
  • Mongoose Version: 4.10.8
  • MongoDB Version:

Call action after insertion

There is a way to call a server side action after insertion ?

When I use forestadmin to insert data on my database, I would like to call my server for create another thing (API Call)
There is an automatic way to do this ? without create all server routine ?

Undefined id, impossible to use admin

Expected behavior

I expected to see the mongo id _id in the id column

Actual behavior

Column id is full of undefined
screenshot 2018-09-20 at 17 02 03

Context

  • Package Version: 2.14.0
  • Express Version: 4.16.3
  • Mongoose Version: 5.2.16
  • MongoDB Version: 3.4.4

Validation fails for array fields when value have leading whitespace

(posting this here but it might be related to forest-express in general)
Steps to reproduce:

const UserSchema = new mongoose.Schema({
    type:           { type: String, enum: ['New Lead', 'Lead', 'User' ,'Customer']},
    ....
    problem:        [ { type: String, enum: ['Value1', 'Value2', 'Value3',]}],
});
module.exports = mongoose.model('User', UserSchema );

Edit Problem field in the UI. Set value to Value1,Value2 (no space after the ,) and save.
Value is loaded to the screen as Value1, Value2 (with whitespace). Change Value2 to Value3 (keep the whitespace) and save.

You get an error message

Validation failed: problem.1: ` Value3` is not a valid enum value for path `problem`.

Expected: either allow save with leading whitespace or make sure data is loaded top screen without whitespace.

Cannot set property because of object depth

Expected behavior

I should be able to access a collection in ForestAdmin

Actual behavior

I get the message "Oops, something went wrong" when I try to access a collection

Failure Logs

error [forest] 🌳🌳🌳  Unexpected error: Cannot set property 'stats' of null
Cannot set property 'stats' of null
    at /var/app/node_modules/forest-express/dist/serializers/resource.js:60:29
    at arrayMap (/var/app/node_modules/forest-express/node_modules/lodash/lodash.js:614:23)
    at Function.map (/var/app/node_modules/forest-express/node_modules/lodash/lodash.js:8561:14)
    at getAttributesFor (/var/app/node_modules/forest-express/dist/serializers/resource.js:46:9)
    at /var/app/node_modules/forest-express/dist/serializers/resource.js:64:13
    at arrayMap (/var/app/node_modules/forest-express/node_modules/lodash/lodash.js:614:23)
    at Function.map (/var/app/node_modules/forest-express/node_modules/lodash/lodash.js:8561:14)
    at getAttributesFor (/var/app/node_modules/forest-express/dist/serializers/resource.js:46:9)
    at ResourceSerializer.perform (/var/app/node_modules/forest-express/dist/serializers/resource.js:149:5)
    at /var/app/node_modules/forest-express/dist/routes/resources.js:24:140
    at tryCatcher (/var/app/node_modules/forest-express-mongoose/node_modules/bluebird/js/main/util.js:24:31)
    at Promise._settlePromiseFromHandler (/var/app/node_modules/forest-express-mongoose/node_modules/bluebird/js/main/promise.js:454:31)
    at Promise._settlePromiseAt (/var/app/node_modules/forest-express-mongoose/node_modules/bluebird/js/main/promise.js:530:18)
    at Promise._settlePromises (/var/app/node_modules/forest-express-mongoose/node_modules/bluebird/js/main/promise.js:646:14)
    at Async._drainQueue (/var/app/node_modules/forest-express-mongoose/node_modules/bluebird/js/main/async.js:177:16)
    at Async._drainQueues (/var/app/node_modules/forest-express-mongoose/node_modules/bluebird/js/main/async.js:187:10)
    at Immediate.Async.drainQueues (/var/app/node_modules/forest-express-mongoose/node_modules/bluebird/js/main/async.js:15:14)
    at runCallback (timers.js:789:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5)

Context

The issue seems to come from the depth of my model

new Schema({
  // ...
  meta: {
    stats: {
      updatedAt: {type: Date, default: Date.now()},
      // ...
    }
  }
})

I could fix this by adding a condition if (!_.isNil(dest) && _.isPlainObject(field.type)) here https://github.com/ForestAdmin/forest-express/blob/8bd2bb1e91c29c7955dd82a951b868044519cab6/src/serializers/resource.js#L59.
But it's a parent project, so I don't know the consequences this fix can have on forest-express-sequelize.

  • Package Version: 2.12.0
  • Express Version: 4.16.2
  • Mongoose Version: 5.2.4
  • MongoDB Version: 3.6.3

[+] Forms - Embedded arrays containing "deep" embedded documents are json inputs

Expected behavior

Display array of embedded documents as related data

Actual behavior

Displayed as json in the parent document

Context

I have a Society with an array of Member embedded. Members are displayed in "details" and not in Related Data. I tried to create a fake field as a workaround with:

{ field: '_members', type: ['String'], reference: 'Society.members' }

but it try to display societies (whereas I guessed the model put in Liana.ResourceSerializer(Liana, Member... would say to forest "hey it's a Member")

  • Package Version: 2.13.1
  • Express Version: 4.15.4
  • Mongoose Version: 4.10.8
  • MongoDB Version: 3.4.9

Allow reading only specific files

Expected behavior

Currently our models directory has tests associated with the model and 2 other utils files. Should be able to point to directory and let the liana read only a whitelisted set of files and ignore all other files.

Actual behavior

Even if we specifically say to only include "request" and "user" it reads all the other files and breaks, because the dependencies for mocha are not present.

Context

  • Package Version: ^2.14.2
  • Express Version: ^4.15.4
  • Mongoose Version: ^5.2.13
  • MongoDB Version: 3.6

Field Names - Field names beginning with an underscore break the list view

Impossible to query list of my users. Something strange with sub-keys of model

[forest] 🌳🌳🌳 Unexpected error in the list view:

My model

const UserSchema = new Schema({
  email    : { type: String, required: true, lowercase: true },
  locale   : String,
  ...

  _facebook: {
    id        : String,
    name      : String,
    first_name: String,
    last_name : String
  },
  ...

});

module.exports = UserSchema;

Output error

Error message : "No model was found for 'forest-users-facebook'"

[*] Charts - Filters using related data break custom charts

Expected behavior

When creating a custom chart with a filter that is applied to related data (using only the options provided in the UI), I expect the chart to render correctly using only the filtered data.

Actual behavior

The chart breaks, with UI error "Forest cannot render this error." :(

Failure Logs

Successful setup UI:

screen shot 2018-06-14 at 2 31 06 pm

Then adding a filter using a related document:

screen shot 2018-06-14 at 2 32 10 pm

... and we see this.

screen shot 2018-06-14 at 2 32 33 pm

Trying with another related document, using a string-matching query, gives the same error:

screen shot 2018-06-14 at 2 33 38 pm

Error log from server (from first failed attempt):

οΏ½OPTIONS /forest/VideoContent?fields%5BVideoContent%5D=_id%2Ctitle%2Cduration%2Corganization_id&fields%5Borganization_id%5D=name&page%5Bnumber%5D=1&page%5Bsize%5D=30&searchExtended=0&sort=title&timezone=-05%3A00 οΏ½204 οΏ½0.276 ms - 0οΏ½
οΏ½GET /forest/VideoContent?fields%5BVideoContent%5D=_id%2Ctitle%2Cduration%2Corganization_id&fields%5Borganization_id%5D=name&page%5Bnumber%5D=1&page%5Bsize%5D=30&searchExtended=0&sort=title&timezone=-05%3A00 οΏ½200 οΏ½23.188 ms - 16326οΏ½
�[forest] 🌳🌳🌳  Unexpected error: $and/$or/$nor must be a nonempty array
MongoError: $and/$or/$nor must be a nonempty array
    at queryCallback (/Users/tannerwelsh/Code/Swayable/swayable-app/node_modules/mongodb-core/lib/cursor.js:223:25)
    at /Users/tannerwelsh/Code/Swayable/swayable-app/node_modules/mongodb-core/lib/connection/pool.js:541:18
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)οΏ½
οΏ½POST /forest/stats/Response οΏ½500 οΏ½17.612 ms - 77οΏ½

Error log from server (from second failed attempt):

οΏ½OPTIONS /forest/Survey?fields%5BSurvey%5D=_id%2Cname%2Corganization_id%2ClaunchAt%2CcloseAt%2Cpretest%2CcompletionCode%2CpreviewLink%2Cstate&fields%5Borganization_id%5D=name&page%5Bnumber%5D=1&page%5Bsize%5D=20&searchExtended=0&sort=-closeAt&timezone=-05%3A00 οΏ½204 οΏ½0.167 ms - 0οΏ½
οΏ½GET /forest/Survey?fields%5BSurvey%5D=_id%2Cname%2Corganization_id%2ClaunchAt%2CcloseAt%2Cpretest%2CcompletionCode%2CpreviewLink%2Cstate&fields%5Borganization_id%5D=name&page%5Bnumber%5D=1&page%5Bsize%5D=20&searchExtended=0&sort=-closeAt&timezone=-05%3A00 οΏ½200 οΏ½489.506 ms - 6619688οΏ½
�[forest] 🌳🌳🌳  Unexpected error: $and/$or/$nor must be a nonempty array
MongoError: $and/$or/$nor must be a nonempty array
    at queryCallback (/Users/tannerwelsh/Code/Swayable/swayable-app/node_modules/mongodb-core/lib/cursor.js:223:25)
    at /Users/tannerwelsh/Code/Swayable/swayable-app/node_modules/mongodb-core/lib/connection/pool.js:541:18
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)οΏ½
οΏ½POST /forest/stats/Response οΏ½500 οΏ½7.300 ms - 77οΏ½

Context

  • Package Version: 2.7.0
  • Express Version: 4.16.2
  • Mongoose Version: 5.0.14
  • MongoDB Version: 3.6.3

Relevant Schema Code

const ResponseSchema = new Schema({
  survey_id: { type: Schema.Types.ObjectId, required: true, ref: 'Survey' },
  content_id: { type: Schema.Types.ObjectId, required: true, ref: 'Content' },
  startTime: { type: Date, required: true },
  endTime: { type: Date, required: true },
  // ...
})

mongoose.model('Response', ResponseSchema)

// ...

const SurveySchema = new Schema({
  name: { type: String, required: true },
  // ...
})

mongoose.model('Survey', SurveySchema)

// ...

const ContentSchema = new Schema({
  title: { type: String, required: true },
  // ...
})

mongoose.model('Content', ContentSchema)

Can't use site at all

Hi there,
I just wanted to try to register and use Forest Admin. I used the signup form, entered my info, and actually entered the admin panel (didn't receive any e-mail for that). I tried to use the standard 'users' collection, and then I just got redirected to my url:

https://app.forestadmin.com/1096/login

BUT it's stating Unlock Test Admin β€’ Development -> your forest password.

And no matter what I do - I cannot unlock it (even though I enter my password). I even reset it (got e-mail and updated my pass) - still no luck.

THERE IS NO CONTACT INFO on the website! How can you think people will spend money on something they can't even reach! What a shame...

Not to mention it somehow tries to connect to my provided url, which as an example was localhost. Had to open a tunnel and it still didn't work out..

Is there any real way to actually try your service?

Support nested custom schemas for models

Hi,
Is there a chance you can add support for custom schemas inside a model?
For example, lets say i have a user model, and on of its fields is a custom schema, lets say

var subscriptionSchema = new mongoose.Schema({
  type: {
    type: String,
    enum: ['type1', 'type2', 'type3'],
  },
  data: mongoose.Schema.Types.Mixed,
  expires_at: Date
});

And in the user schema we have among others:

userSchema = new mongoose.Schema({
    subscription: subscriptionSchema
});

Right now there is no way to handle or visualize those in the admin panel, they just appear as objects.

forest UI display wrong enum when using same-name subfields

Expected behavior

assume a model like this:

const UserSchema = new mongoose.Schema({
    type:           { type: String, enum: ['New Lead', 'Lead', 'User']},
    name: {
        first:      { type: String, trim: true, },
        last:       { type: String, trim: true, },
    },
    comment:        { type: String, trim: true },
    email:          { type: String, trim: true, },
    weight: {
        value:      { type: Number, min: 30,  validate: Number.isInteger},
        unit:       { type: String, enum: ['kgs', 'lbs']}
    },
    height: {
        value:      { type: Number,  validate: Number.isInteger },
        unit:       { type: String, enum: ['cm', 'in'] }
    },
....

in the forest admin UI it is expected that the unit field for height would show a dropdown with 'cm' and 'in'

Actual

the dropdown display 'kgs' and 'lbs'
screen shot 2017-11-26 at 15 19 58

Details

  • Package Version: "forest-express-mongoose": "^1.4.9",
  • Express Version: "express": "^4.15.4",
  • Mongoose Version: "mongoose": "^4.11.9",
  • MongoDB Version: db version v3.4.9 git version: 876ebee8c7dd0e2d992f36a848ff4dc50ee6603e

Running into RangeOverflow Error when setting up the liana

Expected behavior

I expect the liana to not throw errors and add the /forest route to my app.

Actual Behavior

It throws an error.

[forest] 🌳🌳🌳  An error occured while computing the Forest apimap. Your application apimap cannot be sent to Forest. Your Admin UI might not reflect your application models.
RangeError: Maximum call stack size exceeded
    at /Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:70:39
    at Array.forEach (<anonymous>)
    at unflatten (/Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:70:23)
    at /Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:98:23
    at Array.forEach (<anonymous>)
    at unflatten (/Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:70:23)
    at /Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:98:23
    at Array.forEach (<anonymous>)
    at unflatten (/Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:70:23)
    at /Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:98:23
    at Array.forEach (<anonymous>)
    at unflatten (/Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:70:23)
    at /Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:98:23
    at Array.forEach (<anonymous>)
    at unflatten (/Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:70:23)
    at /Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:98:23
    at Array.forEach (<anonymous>)
    at unflatten (/Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:70:23)
    at /Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:98:23
    at Array.forEach (<anonymous>)
    at unflatten (/Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:70:23)
    at /Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:98:23
    at Array.forEach (<anonymous>)
    at unflatten (/Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:70:23)
    at /Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:98:23
    at Array.forEach (<anonymous>)
    at unflatten (/Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:70:23)
    at /Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:98:23
    at Array.forEach (<anonymous>)
    at unflatten (/Users/roopak/workspace/repo/node_modules/forest-express-mongoose/node_modules/flat/index.js:70:23)
From previous event:
    at Object.perform (/Users/roopak/workspace/repo/node_modules/forest-express/dist/generators/schemas.js:14:14)
    at /Users/roopak/workspace/repo/node_modules/forest-express/dist/index.js:152:20
    at __NR_wrappedThenHandler (/Users/roopak/workspace/repo/node_modules/newrelic/lib/instrumentation/promise.js:468:25)
    at runCallback (timers.js:789:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5)
From previous event:
    at Promise.__NR_wrappedThen [as then] (/Users/roopak/workspace/repo/node_modules/newrelic/lib/instrumentation/promise.js:426:23)
    at Object.exports.init (/Users/roopak/workspace/repo/node_modules/forest-express/dist/index.js:149:50)
    at Object.exports.init (/Users/roopak/workspace/repo/node_modules/forest-express-mongoose/index.js:167:20)
    at Object.<anonymous> (/Users/roopak/workspace/repo/server/web.js:30:44)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.wrappedLoad [as _load] (/Users/roopak/workspace/repo/node_modules/newrelic/lib/shimmer.js:342:38)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/roopak/workspace/repo/index.js:25:1)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

Please provide any relevant information about your setup.

  • Package Version: ^2.13.1
  • Express Version: ^4.15.4
  • Mongoose Version: ^4.11.11
  • MongoDB Version: 3.4

mongoose virtuals are not available to custom fields getter function

//models/MyModel.js
const mongoose = require('mongoose');
const MyModelSchema = new mongoose.Schema({
    f1:               { type: String },
},{autoIndex: true, toObject: { virtuals: true }, toJSON: { virtuals: true }});

MyModelSchema.virtual('forest').get( function () {
    return 'found';
});
module.exports = mongoose.model('MyModel',MyModelSchema);

//forest/MyModel.js
const Liana = require('forest-express-mongoose');

Liana.collection('mymodels', {
    fields: [
        {field: 'forest',      type: 'String',  get: o => { return o.forest || 'lost'; }},
    ]
});

//result -> 'lost'

Since the mongoose ResourcesGetter is using lean queries it does not run mongoose virtuals. Please consider adding a flag to allow running mongoose virtuals. This can be done by either removing the lean() from ReasourcesGetter (line 206 on master) or by implementing something similar to mongoose-lean-virtuals npm.
Again this should only be done on explicit request from the user (e.g. based on collection settings)

Mongoose hooks

Expected behavior

I would expect that mongoose hooks are executed, eg pre('save', ...

Actual behavior

When saving a document through the forest admin interface, the document is updated in the database but hook was never executed.

Hook does execute when I run the save() function in my code.

Context

  • Package Version: 2.14.2
  • Express Version: 4.16.3
  • Mongoose Version: 5.3.1
  • MongoDB Version: 3.6.8

Node process exit when adding some references fields filters

Expected behavior

The expected behavior is to get the references filter working for all collections in all collections.

Actual behavior

Some collections have references fields on others collections (often large amount of data) and when triyng to add a filter with this references fields, after a few times, i get :

  • 'Data cannot be reach' on the browser,
  • On the browser console a Failed to load resource: the server responded with a status of 504 (GATEWAY_TIMEOUT)
  • The node process exit with a FATAL ERROR due to JavaScript heap out of memory
  • The API reboot making all the stack unavailable during 2 minutes

I tried to increase the size of the memory allocated to the node process with
the option --max-old-space-size without success.

Failure Logs

The Node JS Failure log is

<--- Last few GCs --->

[25176:0x103000000] 175050 ms: Mark-sweep 1492.9 (1566.7) -> 1492.7 (1535.7) MB, 1287.0 / 0.0 ms last resort GC in old space requested
[25176:0x103000000] 176334 ms: Mark-sweep 1492.7 (1535.7) -> 1492.7 (1535.7) MB, 1284.4 / 0.0 ms last resort GC in old space requested

<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x3ac7b79a5749
1: push(this=0x3ac7a157ac59 <JSArray[60167]>)
2: /* anonymous /(aka / anonymous */) [/..../node_modules/mongodb/lib/operations/cursor_ops.js:226] [bytecode=0x3ac7eb16d639 offset=292](this=0x3ac718e822d1 ,err=0x3ac718e82201 ,doc=0x3ac795dd0ee9 )
3: handleCallback(aka handleCallback) [/.../api/node...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [/usr/local/bin/node]
2: node::FatalException(v8::Isolate*, v8::Localv8::Value, v8::Localv8::Message) [/usr/local/bin/node]
3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
4: v8::internal::Factory::NewUninitializedFixedArray(int) [/usr/local/bin/node]
5: v8::internal::(anonymous namespace)::ElementsAccessorBase<v8::internal::(anonymous namespace)::FastPackedObjectElementsAccessor, v8::internal::(anonymous namespace)::ElementsKindTraits<(v8::internal::ElementsKind)2> >::ConvertElementsWithCapacity(v8::internal::Handlev8::internal::JSObject, v8::internal::Handlev8::internal::FixedArrayBase, v8::internal::ElementsKind, unsigned int, unsigned int, unsigned int, int) [/usr/local/bin/node]
6: v8::internal::(anonymous namespace)::ElementsAccessorBase<v8::internal::(anonymous namespace)::FastPackedObjectElementsAccessor, v8::internal::(anonymous namespace)::ElementsKindTraits<(v8::internal::ElementsKind)2> >::GrowCapacityAndConvertImpl(v8::internal::Handlev8::internal::JSObject, unsigned int) [/usr/local/bin/node]
7: v8::internal::(anonymous namespace)::ElementsAccessorBase<v8::internal::(anonymous namespace)::FastPackedObjectElementsAccessor, v8::internal::(anonymous namespace)::ElementsKindTraits<(v8::internal::ElementsKind)2> >::Add(v8::internal::Handlev8::internal::JSObject, unsigned int, v8::internal::Handlev8::internal::Object, v8::internal::PropertyAttributes, unsigned int) [/usr/local/bin/node]
8: v8::internal::JSObject::AddDataElement(v8::internal::Handlev8::internal::JSObject, unsigned int, v8::internal::Handlev8::internal::Object, v8::internal::PropertyAttributes, v8::internal::Object::ShouldThrow) [/usr/local/bin/node]
9: v8::internal::Runtime_SetProperty(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
10: 0x32cb009842fd

Context

  • Package Version: 2.14.0
  • Express Version: 4.16.2
  • Mongoose Version: 5.2.14
  • MongoDB Version: 3.1.6 (package.json) | 4.0.2 (remote DB)

express route is not recognized

Hi,

I used the mongodb "simple" example to create an Express app for Forest.
But as I created a route to a new Smart Action, my Express app sends a 404 code every time I try to call this Smart Action.

Can you confirm I just need to add this line to a file inside the route folder ?

router.post('/forest/actions/add-client', liana.ensureAuthenticated, addClient)

Admin interface does not show value 0 for Number field on nested objects

Steps to reproduce:

  1. Create a model like this:
module.exports.Example = mongoose.model('Example', new mongoose.Schema({
    title:      { type: String, },
    type:       { type: String, enum: ['buttons','select','form']},
    buttons:    [{
        title: String,
        value: Number
    }],
    fields:     [{
        title: String,
        ftype: { type: String, enum: ['select', 'input']},
        values: { type: Array },
    }]
}));
  1. Go to Forest Admin
  2. Add a new Example
  3. Add two buttons
  4. Button 1: title=Yes, Value=100
  5. Button 2: title=No, Value=0
  6. Save Example object
  7. Button 2 does not show the value in the admin interface

Is modelsDir option needed?

I noticed that there is no mention of modelsDir when I search the source code of the project. I am also seeing that there is a getModels function which actually gets the models from mongoose.models. So is modelsDir actually a required configuration option?

I am asking because our models are enclosed in functions like:

module.exports = function (app) {
    return new Schema({ ... })
}

and so we can't really pass a models folder to forest-express-mongoose without some build step first.

[+] Polymorphism Mongoose refPath Support

cancelledBy: { type: mongoose.Schema.Types.ObjectId, refPath: 'cancelledByUserType' }

This kind of refPath instead of ref is not working. I know it's a new feature. It would be great if this feature is provided.

SMART FIELD RETURN OBJECT

Hi, I am trying to return an object to a smart field, here is my code ;

 varvar  LianaLiana  ==  requirerequire(('forest-express-mongoose''forest-express );

Liana.collection('users', {
  fields: [{
    field: 'feed answer',
   type: 'Object',
    get: function (object) {
      return {1:'text',2:'texrt'};
    }
  }]
});

but I am getting
screen shot 2018-05-01 at 14 27 10

Vulnerability in moment/lodash dependency

Expected behavior

To not trigger a security failure on my internal pipeline :)

##Β Actual behavior

lodash and moment packages trigger warnings.

Failure Logs

β”‚ β”‚ Regular Expression Denial of Service β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Name β”‚ moment β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ CVSS β”‚ 7.5 (High) β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Installed β”‚ 2.18.1 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Vulnerable β”‚ <2.19.3 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Patched β”‚ >=2.19.3 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Path β”‚ [email protected] > [email protected] > [email protected] β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ More Info β”‚ https://nodesecurity.io/advisories/532 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ β”‚ Prototype Pollution β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Name β”‚ lodash β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ CVSS β”‚ 2 (Low) β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Installed β”‚ 3.9.3 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Vulnerable β”‚ <4.17.5 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Patched β”‚ >=4.17.5 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Path β”‚ [email protected] > [email protected] > [email protected] β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ More Info β”‚ https://nodesecurity.io/advisories/577

SIMILAR TO ForestAdmin/forest-express#131

Dashboard query error - The 'cursor' option is required, except for aggregate

Expected behavior

I created a chart on the dashboard which is a single value, on a collection called Users and I am just using the Count view to get the number of users with no filters. It runs this this mongoose command (observed in my server log)

users.aggregate([ { '$group': { _id: null, total: { '$sum': 1 } } } ], {})

##Β Actual behavior

I get an error in my server log and the dashboard widget fails to show data.

Failure Logs

Unexpected error: The 'cursor' option is required, except for aggregate with the explain argument MongoError: The 'cursor' option is required, except for aggregate with the explain argument

Context

By way of googling, it seems that the error is caused because I am using Mongo 3.6, so I suppose the mongoose query needs changing

  • Package Version:
  • Express Version: ^4.15.2
  • Mongoose Version: ^4.9.7
  • MongoDB Version: 3.6.4

Can't use import or async or any other ES6 features in Forest config

Hi, when i try to config forest like that :

'use strict';
const Liana = require('forest-express-mongoose');
const Debug  = require('debug')

const debug = Debug(('app:config:functions:forest'))

debug.log = console.log.bind(console)



Liana.collection('files', {
  fields: [{
    field: 'Signed Url',
    type: 'String',
    get: async function (object) {
      debug('object : ', object);
      return await getSignedUrlAsync(object.path)
    }
  }]
})

i have this error :

[forest] 🌳🌳🌳  Forest customization failed due to a syntax error: Unexpected token function in /Users/gautier/Documents/Projets/______/src/functions/forest/index.js:15
[forest] 🌳🌳🌳  An error occured while computing the Forest apimap. Your application apimap cannot be sent to Forest. Your Admin UI might not reflect your application models.
Error
    at /Users/gautier/Documents/Projets/_____/node_modules/forest-express/index.js:122:23

Seems that ES6 is not supported ?

Smartfield inconsistent behavior

Expected behavior

I'd like to add smart fields to my collections

##Β Actual behavior

Some smart fields work some don't whereas they are defined in the same way, some stop working some start to, without any code change...

Failure Logs

none
logs in the smart fields get return the expected value which (most of the time) is not visible in the admin

Maybe due to the loading sequence?

Not possible to search an array of strings (tags)

I'm having trouble to search through an array of strings, defined in my model as shown below.

var Product = new Schema({
  title: { type: String, required: true },
  description: { type: String, required: true },
  tags: [{type: String}],
  createdAt: { type: Date },
  updatedAt: { type: Date }
});

The field does appear within Forest admin but as a comma separated text field, however it is not possible to create segments or search on this field.

ForestAdmin can't handle a single condition

Expected behavior

I should be able to add a single filter

Actual behavior

If i add a single filter it fails

Failure Logs

0|admin-server  | [forest] 🌳🌳🌳  Unexpected error: $and/$or/$nor must be a nonempty array
0|admin-server  | MongoError: $and/$or/$nor must be a nonempty array
0|admin-server  |     at queryCallback (/Users/roopak/workspace/spoke/node_modules/mongodb-core/lib/cursor.js:248:25)
0|admin-server  |     at /Users/roopak/workspace/spoke/node_modules/mongodb-core/lib/connection/pool.js:532:18
0|admin-server  |     at args.(anonymous function) (/Users/roopak/workspace/spoke/node_modules/event-loop-inspector/index.js:138:29)
0|admin-server  |     at _combinedTickCallback (internal/process/next_tick.js:131:7)
0|admin-server  |     at process._tickDomainCallback [as _tickCallback] (internal/process/next_tick.js:218:9)
0|admin-server  | (node:65144) DeprecationWarning: collection.count is deprecated, and will be removed in a future version. Use collection.countDocuments or collection.estimatedDocumentCount instead

Context

  • Package Version: 2.14.2
  • Express Version: 4.15.4
  • Mongoose Version: 5.2.13
  • MongoDB Version: 3.6

[forest] 🌳🌳🌳 Cannot customize your collection named "users" properly.

Hi,
I add

app.use(require('forest-express-mongoose').init({
    modelsDir: __dirname + '/models',  // Your models directory.
    envSecret: config.forest.env_secret,
    authSecret: config.forest.auth_secret,
    mongoose: mongoose // The database connection.
}));

before my app.listen. And i can see the data in Forest so thats seems okay.

But when i add a file in forest/users.js with

var Liana = require('forest-express-mongoose');
Liana.collection('users', {
    actions: [{ name: 'Ban user' }]
});

nothing append. And if i require that file (despite the fact that it's not advised) i can see :
[forest] 🌳🌳🌳 Cannot customize your collection named "users" properly. Did you call the "collection" method in the /forest directory?

What should i do ?
Thanks

Setup - Mongoosastic support

Expected behavior

postSave called and make use of mongoosastic plugin through the index method which indexes the model in Elasticsearch

Actual behavior

index is undefined

Failure Logs

TypeError: _doc.index is not a function
  File "/app/node_modules/mongoosastic/lib/mongoosastic.js", line 260, col 14, in model.Query.postSave
    _doc.index(onIndex)
  File "/app/node_modules/kareem/index.js", line 186, col 14, in next
    post.apply(context, newArgs);
  File "/app/node_modules/kareem/index.js", line 197, col 3, in Kareem.execPost
    next();
  File "/app/node_modules/kareem/index.js", line 265, col 15, in null.<anonymous>
    _this.execPost(name, context, argsWithoutError, function() {
  File "/app/node_modules/mongoose/lib/query.js", line 2269, col 10, in _completeOneLean
    return callback(null, doc);
  File "/app/node_modules/mongoose/lib/query.js", line 2222, col 16, in null.<anonymous>
    return _completeOneLean(doc, res, opts, callback);
  File "/app/node_modules/mongoose/lib/model.js", line 3835, col 16, in null.<anonymous>
    callback.apply(null, arguments);
  File "/app/node_modules/mongoose/lib/model.js", line 3007, col 5, in next
    callback(null, docs);
  File "/app/node_modules/mongoose/lib/model.js", line 3112, col 12, in populate
    return callback();
  File "/app/node_modules/mongoose/lib/model.js", line 2997, col 5, in _populate
    populate(model, docs, path, next);
  File "/app/node_modules/mongoose/lib/model.js", line 2957, col 5, in Function.Model.populate
    _populate(this, docs, paths, cache, callback);
  File "/app/node_modules/mongoose/lib/query.js", line 2216, col 17, in cb
    _this.model.populate(doc, pop, function(err, doc) {
  File "/app/node_modules/mongoose/lib/query.js", line 2237, col 16, in null.<anonymous>
    return cb(error, res ? res.value : res, res);
  File "/app/node_modules/mongoose/lib/utils.js", line 526, col 16, in null.<anonymous>
    callback.apply(this, arguments);
  File "/app/node_modules/mongodb/lib/utils.js", line 120, col 56, in handleCallback
    return value2 ? callback(err, value1, value2) :  callback(err, value1);
  File "/app/node_modules/mongodb/lib/collection.js", line 2494, col 14, in null.<anonymous>
    return handleCallback(callback, null, result);
  File "/app/node_modules/mongodb/lib/utils.js", line 120, col 56, in handleCallback
    return value2 ? callback(err, value1, value2) :  callback(err, value1);
  File "/app/node_modules/mongodb/lib/db.js", line 315, col 5, in null.<anonymous>
    handleCallback(callback, null, result.result);
  File "/app/node_modules/mongodb-core/lib/connection/pool.js", line 469, col 18, in null.<anonymous>
    return cb(err, result);
  File "/app/node_modules/opbeat/lib/instrumentation/index.js", line 105, col 27, in opbeatCallbackWrapper
    var result = original.apply(this, arguments)
  File "internal/process/next_tick.js", line 131, col 7, in _combinedTickCallback
  File "internal/process/next_tick.js", line 218, col 9, in process._tickDomainCallback [as _tickCallback]

Context

We export our models which already have the mongoosastic plugin mounted but for some reason the index method is undefined in the postSave

  • Package Version: ^2.1.0
  • Express Version: ^4.15.4
  • Mongoose Version: 4.11.11
  • MongoDB Version: 2.2.31

Validation is not being enforced

Hi, is there a way to make sure ForestAdmin adheres to my models' custom validators?

I thought this should work out-of-the-box since this is a mongoose plugin, not just mongo.

For example, I have a validation that makes sure codes are unique across three collections.

Thank you for ForestAdmin. Love it!
Don't know how nobody thought of it before.

Getting table contents fails

Expected behavior

Getting table content should display list

##Β Actual behavior

I'm trying to see my Customers table but it doesnt stop loading. Displays the error in devtools console below.

Server displays the following:

GET /forest/Customer?fields%5BCustomer%5D=name%2C%2Cemail%2Ccreated%2CcustomerType%2Cverified&page%5Bnumber%5D=1&page%5Bsize%5D=10&searchExtended=0&sort=-created&timezone=%2B02%3A00 304 7.048 ms - -

Failure Logs

client-e79e8420abbb48465b3fdeef7da2b9fc.js:formatted:2008 TypeError: Cannot read property 'namespace' of undefined
    at i.<anonymous> (client-e79e8420abbb48465b3fdeef7da2b9fc.js:formatted:4098)
    at c.p.get (vendor-2f3d96ac8d0efb85bc0667e81366761b.js:12)
    at Object.r [as get] (vendor-2f3d96ac8d0efb85bc0667e81366761b.js:13)
    at i.get (vendor-2f3d96ac8d0efb85bc0667e81366761b.js:16)
    at client-e79e8420abbb48465b3fdeef7da2b9fc.js:formatted:11077
    at Array.map (<anonymous>)
    at client-e79e8420abbb48465b3fdeef7da2b9fc.js:formatted:11073
    at A (vendor-2f3d96ac8d0efb85bc0667e81366761b.js:24)
    at k (vendor-2f3d96ac8d0efb85bc0667e81366761b.js:24)
    at vendor-2f3d96ac8d0efb85bc0667e81366761b.js:24

Context

  • Package Version: 2.8.4
  • Express Version: 4.16.3
  • Mongoose Version: 5.1.1
  • MongoDB Version: 3.6.4

Error with chart: Cannot read property 'reference' of undefined

Expected behaviour

I created a Repartition chart that for one of my models. The "Group By" is set to a field that, in my model is a ref to another model. The UI sends this in the body of the request

{
  aggregate:"Count"
  collection:"Recording"
  filters:[]
  group_by_field:"organisation:name"
  query:null
  time_range:null
  timezone:"+01:00"
  type:"Pie"
}

##Β Actual behaviour

I get an error response back from the API "Cannot read property 'reference' of undefined" with this stack

If I curl the request the UI makes, but change the body so that the field group_by_field equals organisation rather than organisation:name, it works! So not sure if the UI should change or the API.

Failure Logs

TODO: Please include any relevant log snippets, if necessary.

TypeError: Cannot read property 'reference' of undefined
    at getReference (/node_modules/forest-express-mongoose/services/pie-stat-getter.js:17:18)
    at PieStatGetter.perform (/node_modules/forest-express-mongoose/services/pie-stat-getter.js:35:32)
    at get (/node_modules/forest-express/dist/routes/stats.js:20:79)
    at Layer.handle [as handle_request] (/node_modules/forest-express/node_modules/express/lib/router/layer.js:95:5)
...

TODO: Please provide any relevant information about your setup.

  • Package Version:2.9.0
  • Express Version: 4.15.2
  • Mongoose Version: 5.1.2
  • MongoDB Version: 3.6

[*] Charts - ForestAdmin gets confused when dealing with model references in charts

Expected behavior

When I build a chart I should be able to to filter by the presence or non presence of a field which is a reference to another model

Actual behavior

ForestAdmin forces me to pick a subfield from the other model. What makes it worse is that the submodel is not populated n the query and this causes the graph to be wrong.

Failure Logs

NA

Context

My models look as follows

Request {
id: ...
...
requestType: {
ref: RequestType,
type: ObjectId
}
}

Now i want to make a condition: request.requestType is present. your current liana doesnt let me do so.
If I add request.requestType.id is present, it seems to ignore this, because I dont this field is populated by default.

[SmartActions] Is there a way to set a custom URL to POST to for an action?

Hello,

From what I've seen here http://doc.forestadmin.com/developers-guide/#creating-an-action and in trying to create a smart action Forest expects the URL for a smart action to be smth like: /forest/actions/action-name

Is there any way you can set a custom URL for the API when you define the smart action? Smth like this:

var Liana = require('forest-express-mongoose');

Liana.collection('customers', {
  actions: [{ name: 'Ban user', url: '/your-custom-url' }]
});

Thank you!

[*] Array of Subdocuments - Support Enums

Hello

It's possible duplicate of BUG #44 marked as resolved,
but I found an issue on my schema,
If I use an enum in an array, forest don't show the select

content : { type: [ { locale : { type : String, enum : ['FR_FR', 'AR_AR'], required : true, default : 'FR_FR' } } ], required: true, validate: [(value) => value.length > 0, 'YOU MUST SELECT CONTENT'], },

46302331-ae080300-c5a0-11e8-8b74-65b2a4122f90

Meta `count` not working on Serializer

Hi,
Following this tutorial : https://doc.forestadmin.com/developer-guide/express-mongoose.html#example-hasmany-smart-relationship

The count params don't work.

For :

const serialized = await new Serializer(Liana, Letters, results.docs, {}, {
     count: results.total
    // Don't seem to work
}).perform()
debug('serialized : %O', serialized)

I don't see the { meta : { count : NUMBER } }

Temporary fix to have pagination working:

return res.send({...serialized, meta : {count : results.total}})

Custom nested schemas not serialized in list view

On list view i see something like <client@model:forest-users-someschema::ember5328:owner(XXXXXXXX)> for custom types.
I would expect having the serialized content there.

Also in filters i cannot filter by a sub field of the custom schema, is this a separate issue?

Edit form for subdocuments not displaying properly

Hi,

I believe there are a couple of bugs when adding a new subdocument in the Forest Admin app.

Firstly, enums correctly display as drop-downs when adding the main document, but in the subdocument there are no inputs at all. Here's an example of a regular string field and two enums it a subdocument:
capture

The other issue is again related to sudocuments. Auto-generated input fields such as id and created_at, updated_at are not disabled.

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.