I'm using i18n-node in my express app and i need to get data from database with getLocale()
"prefix"
updated question
My mongoose Schema
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
var ArticleSchema = new Schema({
title: {
en : {type: String},
it : {type: String},
fr : {type: String},
},
content: {
en : {type: String},
it : {type: String},
fr : {type: String},
},
MyController
exports.list = function (req, res) {
var locale = i18n.getLocale();
console.log('locale',locale); //working -> en
Article.find({'title.locale':locale}).sort('-created').populate('user', 'displayName').exec(function (err, articles) {
if (err) {
return res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
} else {
console.log('articles',articles,'res');
res.json(articles);
}
});
};
I want to get all articles with en
(e.g) prefix.
getLocale()
method returns a locale like en
,it
etc.
How can i build a query "Find all articles where "title (or content) : getLocale()" ?
Even Article.find({'title': 'en'})
not working