Fix conflict

This commit is contained in:
Jim LAURIE 2019-01-28 12:07:08 +01:00
commit 7fe72a755e
4 changed files with 29 additions and 1 deletions

View File

@ -24,6 +24,7 @@ Easily filter results according to fields values.
- `_gt`: Greater than
- `_lte`: Lower than or equal to
- `_gte`: Greater than or equal to
- `_in`: Include in array
- `_contains`: Contains
- `_containss`: Contains case sensitive
@ -37,6 +38,9 @@ Find products having a price equal or greater than `3`.
`GET /products?price_gte=3`
Find multiple product with id 3, 6, 8
`GET /products?id_in=3&id_in=6&id_in=8`
::: note
You can't use filter to have specific results inside relation, like "Find users and only their posts older than yesterday" as example. If you need it, you can modify or create your own service or use [GraphQL](./graphql.md#query-api).
:::

View File

@ -160,6 +160,28 @@ module.exports = function (strapi) {
} else {
this._mongooseOptions.populate[association.alias].path = `${association.alias}.ref`;
}
} else {
if (!this._mongooseOptions.populate) {
this._mongooseOptions.populate = {};
}
// Images are not displayed in populated data.
// We automatically populate morph relations.
if (association.nature === 'oneToManyMorph' || association.nature === 'manyToManyMorph') {
this._mongooseOptions.populate[association.alias] = {
path: association.alias,
match: {
[`${association.via}.${association.filter}`]: association.alias,
[`${association.via}.kind`]: definition.globalId
},
options: {
sort: '-createdAt'
},
select: undefined,
model: undefined,
_docs: {}
};
}
}
next();
});
@ -554,4 +576,4 @@ module.exports = function (strapi) {
}, relations);
return hook;
};
};

View File

@ -61,6 +61,7 @@ module.exports = function (name, cliArguments) {
settings: {
client: cliArguments.dbclient,
host: cliArguments.dbhost,
srv: cliArguments.dbsrv,
port: cliArguments.dbport,
database: cliArguments.dbname,
username: cliArguments.dbusername,

View File

@ -56,6 +56,7 @@ program
.option('--debug', 'Display database connection error')
.option('--dbclient <dbclient>', 'Database client')
.option('--dbhost <dbhost>', 'Database host')
.option('--dbsrv <dbsrv>', 'Database srv')
.option('--dbport <dbport>', 'Database port')
.option('--dbname <dbname>', 'Database name')
.option('--dbusername <dbusername>', 'Database username')