I'm trying to create a sort of newsfeed feature for my app. I'm trying to understand how to do it with a nested query in Mongo/Mongoose rather than using aggregate. (the rest of the app uses nested queries) and I'd prefer to not have to modify the query with vanilla javascript to get the perfect object if I don't need to.
I'd like to get the friends of the current user, for each friend, get all of their posts and then sort it all by date.
I want to make my current query more efficient as there's an extra step
my query in Mongoose
User.findOne({ _id: req.userId }, 'friends.user -_id')
.populate({
path: 'friends.user',
model: 'User',
select: 'posts -_id',
populate: {
path: 'posts',
model: 'Post',
select: 'date author user desc -_id',
options: { sort: { date: -1 } },
populate: {
path: 'author user',
model: 'User',
select: 'profile.firstname profile.lastname profile.avatar username'
},
},
})
the results
{
"newsfeed": [
{
"user": {
"posts": [
{
"user": {
"profile": {
"firstname": "user2",
"lastname": "user2",
"avatar": "c66620a0ef057908a1663725956ac03a.jpg"
},
"_id": "5b56549fcba9231e5d1e848d",
"username": "kenne"
},
"author": {
"profile": {
"firstname": "user1",
"lastname": "user1",
"avatar": "9e7b60e534cf761f41d6afe3d97295c9.jpg"
},
"_id": "5b562382a16cde19638e4bee",
"username": "user1"
},
"date": "2018-07-24T06:40:37.413Z",
"desc": "sdfsdf"
},
{
"user": {
"profile": {
"firstname": "user2",
"lastname": "user2",
"avatar": "c66620a0ef057908a1663725956ac03a.jpg"
},
"_id": "5b56549fcba9231e5d1e848d",
"username": "user2"
},
"author": {
"profile": {
"firstname": "user1",
"lastname": "user1",
"avatar": "9e7b60e534cf761f41d6afe3d97295c9.jpg"
},
"_id": "5b562382a16cde19638e4bee",
"username": "user1"
},
"date": "2018-07-24T06:40:17.180Z"
},
{
"user": {
"profile": {
"firstname": "user2",
"lastname": "user2",
"avatar": "c66620a0ef057908a1663725956ac03a.jpg"
},
"_id": "5b56549fcba9231e5d1e848d",
"username": "user2"
},
"author": {
"profile": {
"firstname": "user2",
"lastname": "user2",
"avatar": "c66620a0ef057908a1663725956ac03a.jpg"
},
"_id": "5b56549fcba9231e5d1e848d",
"username": "user2"
},
"date": "2018-07-23T22:20:15.246Z",
"desc": "Gibberish"
}
]
}
},
{
"user": {
"posts": [
{
"user": {
"profile": {
"firstname": "user3",
"lastname": "user3",
"avatar": "132df94df5733efd41609681bc7f71f9.jpeg"
},
"_id": "5b5382f3661a8d7023e1ae65",
"username": "user3"
},
"author": {
"profile": {
"firstname": "user3",
"lastname": "user3",
"avatar": "132df94df5733efd41609681bc7f71f9.jpeg"
},
"_id": "5b5382f3661a8d7023e1ae65",
"username": "user3"
},
"date": "2018-07-21T19:09:45.543Z",
"desc": "Gibberish"
}
]
}
}
]
}
because I need to first get the friends of the user, the current query creates two user objects each with their own posts and authors and user objects within them.
eg. {"newsfeed": [{"user": {"bios": [...]}}], [{"user": {"bios": [...]}}] }
what I want is something like this
{
"newsfeed": [{
"posts": [
{
"user": {
"profile": {
"firstname": "user2",
"lastname": "user2",
"avatar": "c66620a0ef057908a1663725956ac03a.jpg"
},
"_id": "5b56549fcba9231e5d1e848d",
"username": "user2"
},
"author": {
"profile": {
"firstname": "user1",
"lastname": "user1",
"avatar": "9e7b60e534cf761f41d6afe3d97295c9.jpg"
},
"_id": "5b562382a16cde19638e4bee",
"username": "user1"
},
"date": "2018-07-24T06:40:37.413Z",
"desc": "sdfsdf"
},
{
"user": {
"profile": {
"firstname": "user2",
"lastname": "user2",
"avatar": "c66620a0ef057908a1663725956ac03a.jpg"
},
"_id": "5b56549fcba9231e5d1e848d",
"username": "user2"
},
"author": {
"profile": {
"firstname": "user1",
"lastname": "user1",
"avatar": "9e7b60e534cf761f41d6afe3d97295c9.jpg"
},
"_id": "5b562382a16cde19638e4bee",
"username": "user1"
},
"date": "2018-07-24T06:40:17.180Z"
},
{
"user": {
"profile": {
"firstname": "user2",
"lastname": "user2",
"avatar": "c66620a0ef057908a1663725956ac03a.jpg"
},
"_id": "5b56549fcba9231e5d1e848d",
"username": "user2"
},
"author": {
"profile": {
"firstname": "user2",
"lastname": "user2",
"avatar": "c66620a0ef057908a1663725956ac03a.jpg"
},
"_id": "5b56549fcba9231e5d1e848d",
"username": "user2"
},
"date": "2018-07-23T22:20:15.246Z",
"desc": "Gibberish"
},
{
"user": {
"profile": {
"firstname": "user3",
"lastname": "user3",
"avatar": "132df94df5733efd41609681bc7f71f9.jpeg"
},
"_id": "5b5382f3661a8d7023e1ae65",
"username": "user3"
},
"author": {
"profile": {
"firstname": "user3",
"lastname": "user3",
"avatar": "132df94df5733efd41609681bc7f71f9.jpeg"
},
"_id": "5b5382f3661a8d7023e1ae65",
"username": "user3"
},
"date": "2018-07-21T19:09:45.543Z",
"desc": "Gibberish"
}
]}
How can I do that without using aggregate? to get something more like this
eg. {"newsfeed": [{"posts": [...]}] }
additional info
users
const UserSchema = new Schema({
username : String,
friends : [{ user: { type: Schema.Types.ObjectId, ref: 'User'}, status: String }],
profile: {
name : String,
firstname : String,
lastname : String,
avatar : String
}),
posts : [{ type: Schema.Types.ObjectId, ref: 'Post' }]
});
posts
const PostsSchema = new Schema({
user : { type: Schema.Types.ObjectId, ref: 'User' },
author : { type: Schema.Types.ObjectId, ref: 'User' },
date : Date,
desc : String
});
example data: users
{
"_id" : ObjectId("5b51fd2a3f4ec33546a06648"),
"profile" : {
"firstname" : "user1",
"lastname" : "user1"
"avatar" : "user1.png"
}
"username" : "user1",
"friends" : [
{
"_id" : ObjectId("5b51fd7c3f4ec33546a0664f"),
"user" : ObjectId("5b51fd643f4ec33546a0664c")
},
{
"_id" : ObjectId("5b51fdb53f4ec33546a06655"),
"user" : ObjectId("5b51fd903f4ec33546a06652")
}
]
}
{
"_id" : ObjectId("5b51fd643f4ec33546a0664c"),
"profile" : {
"firstname" : "user2",
"lastname" : "user2"
"avatar" : "user2.png"
}
"posts" : [
{
"_id" : ObjectId("5b51fdcd3f4ec33546a06610"),
"_id" : ObjectId("5b51fdcd3f4ec33546a06611"),
"_id" : ObjectId("5b51fdcd3f4ec33546a06612"),
}
],
"__v" : 5,
"username" : "user2"
},
{
"_id" : ObjectId("5b51fd903f4ec33546a06652"),
"profile" : {
"firstname" : "user3",
"lastname" : "user3"
"avatar" : "user3.png"
},
"posts" : [
{
"_id" : ObjectId("5b51fdce3f4ec33546a06615"),
"_id" : ObjectId("5b51fd2a3f4ec33546a06617")
}
],
"__v" : 5,
"username" : "user3"
}
example date: posts
{
"_id" : ObjectId("5b51fdcd3f4ec33546a06610"),
"user" : ObjectId("5b51fd2a3f4ec33546a06648"),
"author" : ObjectId("5b51fd2a3f4ec33546a06648"),
"date" : ISODate("2018-07-20T15:18:02.962Z"),
"desc" : "user1 gibberish",
"__v" : 0
}
{
"_id" : ObjectId("5b51fdcd3f4ec33546a06611"),
"user" : ObjectId("5b51fd643f4ec33546a0664c"),
"author" : ObjectId("5b51fd643f4ec33546a0664c"),
"date" : ISODate("2018-07-20T15:19:00.968Z"),
"desc" : "user2 gibberish",
"__v" : 0
}
{
"_id" : ObjectId("5b51fdcd3f4ec33546a06612"),
"user" : ObjectId("5b51fd903f4ec33546a06652"),
"author" : ObjectId("5b51fd903f4ec33546a06652"),
"date" : ISODate("2018-07-20T15:19:44.102Z"),
"desc" : "user3 gibberish",
"__v" : 0
}
{
"_id" : ObjectId("5b51fdce3f4ec33546a06615"),
"user" : ObjectId("5b51fd643f4ec33546a0664c"),
"author" : ObjectId("5b51fd643f4ec33546a0664c"),
"date" : ISODate("2018-07-20T15:19:00.968Z"),
"desc" : "more gibberish",
"__v" : 0
}
{
"_id" : ObjectId("5b51fdce3f4ec33546a06616"),
"user" : ObjectId("5b51fd903f4ec33546a06652"),
"author" : ObjectId("5b51fd903f4ec33546a06652"),
"date" : ISODate("2018-07-20T15:19:44.102Z"),
"desc" : "more gibberish",
"__v" : 0
}
You could try unrolling the items in the application layer with the following code
User.find({ _id: mongoose.Types.ObjectId("5b51fd2a3f4ec33546a06648") }, 'friends.user -_id')
.populate({
path: 'friends.user',
model: 'User',
select: 'posts -_id',
})
.exec(function(err, results) {
// Post.find({ _id: {$in: results
const postIDs = results.reduce((acc, user) => {
return acc.concat(
...user.friends.map(
friend => friend.user.posts
)
)
}, [])
Post.find({ _id: { $in: postIDs } })
.populate(
{
path: 'author user',
model: 'User',
select: 'profile.firstname profile.lastname profile.avatar username'
}
)
.exec(function(err, posts) {
console.log(
JSON.stringify(posts, null, 2)
);
})
});
Other option is map reduce, but since you don't like aggregation, I'm not sure map reduce is appropriate either.
const mapReduceConfig = {
map: function() {
var friends = this.friends;
emit(
this._id,
friends.reduce(
(acc, friend) => {
return acc.concat(
friend.posts &&
friend.posts.reduce((pacc, p) => pacc.concat(p), [])
) || [];
},
[]
)
);
},
reduce: function(k, vals) {
return Array.sum(vals);
}
};
User.mapReduce(mapReduceConfig, function(err, results) {
console.log(
JSON.stringify(results, null, 2)
);
});
Related
My book collection looks like this:
{
"book": {
"title": "Book1",
"author": "Tom"
},
"quantity": 3
},
{
"book": {
"title": "Book2",
"author": "Tom"
},
"quantity": 4
},
{
"book": {
"title": "Book3",
"author": "Dick"
},
"quantity": 9
},
{
"book": {
"title": "Book4",
"author": "Harry"
},
"quantity": 6
},
{
"book": {
"title": "Book5",
"author": "Chris"
},
"quantity": 7
},
{
"book": {
"title": "Book6",
"author": "Dick"
},
"quantity": 10
}
This collection has book documents with title, author and quantity.
I want help in coming up with aggregation which would output the array of authors with their books and quantity. Example - Tom has authored "Book1" and "Book2", "Dick" has authored "Book6" and "Book3".
authors: [
{
"name": "Tom",
"books": [
{
"title": "Book1",
"quantity": "3"
},
{
"title": "Book2",
"quantity": "4"
}
]
},
{
"name": "Dick",
"books": [
{
"title": "Book6",
"quantity": "10"
},
{
"title": "Book3",
"quantity": "9"
}
]
},
{
"name": "Harry",
"books": [
{
"title": "Book4",
"quantity": "6"
}
]
}
]
Try this aggregation:
db.collection.aggregate([{
$group: {
_id: "$book.author",
books: {
$push: {
title: "$book.title",
quantity: "$quantity"
}
}
}},{
$project: {
"name": "$_id",
"books": 1,
"_id": 0
}}])
I tried it on mongo playground:
https://mongoplayground.net/p/m-QbX-uzkkt
Try as below:
db.collection.aggregate([
{
$group: {
_id: "$book.author",
books: { $push: { "title": "$book.title", "quantity": "$quantity"} }
},
}
])
Output will be
/* 1 */
{
"_id" : "Chris",
"books" : [
{
"title" : "Book5",
"quantity" : 7
}
]
},
/* 2 */
{
"_id" : "Harry",
"books" : [
{
"title" : "Book4",
"quantity" : 6
}
]
},
/* 3 */
{
"_id" : "Dick",
"books" : [
{
"title" : "Book3",
"quantity" : 9
},
{
"title" : "Book6",
"quantity" : 10
}
]
},
/* 4 */
{
"_id" : "Tom",
"books" : [
{
"title" : "Book1",
"quantity" : 3
},
{
"title" : "Book2",
"quantity" : 4
}
]
}
How do I get a summary count in Mongo. I have the following record structure and I would like to get a summary by date and status
{
"_id": "1",
"History": [
{
"id": "11",
"message": "",
"status": "send",
"resultCount": 0,
"createdDate": "",
"modifiedDate": ""
},
{
"id": "21",
"message": "",
"status": "skipped",
"resultCount": 0,
"createdDate": "",
"modifiedDate": ""
}
]
}
This is what I would like..
date x
status :
count : nn
This is my Mongo structure
Let's assume you have the following data in 'history' collection:
{
"_id": "1",
"History": [
{
"id": "21",
"message": "",
"status": "send",
"resultCount": 0,
"createdDate": "date1",
"modifiedDate": ""
},
{
"id": "22",
"message": "",
"status": "skipped",
"resultCount": 0,
"createdDate": "date1",
"modifiedDate": ""
},
{
"id": "23",
"message": "",
"status": "skipped",
"resultCount": 0,
"createdDate": "date2",
"modifiedDate": ""
},
{
"id": "24",
"message": "",
"status": "skipped",
"resultCount": 0,
"createdDate": "date2",
"modifiedDate": ""
}
]
}
You can design your query in the following way to get the desired summary.
db.history.aggregate([
{
$unwind:"$History"
},
{
$group:{
"_id":{
"createdDate":"$History.createdDate",
"status":"$History.status"
},
"createdDate":{
$first: "$History.createdDate"
},
"status":{
$first:"$History.status"
},
"count":{
$sum:1
}
}
},
{
$group:{
"_id":"$createdDate",
"createdDate":{
$first:"$createdDate"
},
"info":{
$push:{
"status":"$status",
"count":"$count"
}
}
}
},
{
$project:{
"_id":0
}
}
]).pretty()
It would result in the following:
{
"createdDate" : "date1",
"info" : [
{
"status" : "skipped",
"count" : 1
},
{
"status" : "send",
"count" : 1
}
]
}
{
"createdDate" : "date2",
"info" : [
{
"status" : "skipped",
"count" : 2
}
]
}
Aggregation stages details:
Stage I: The 'History' array is unwinded i.e. the array would be split and each element would create an individual document.
Stage II: The data is grouped on the basis of 'createdDate' and 'status'. In this stage, the count of status is also calculated.
Stage III: The data is further grouped on the basis of 'createdDate'
only
Stage IV: Eliminating non-required fields from the result
first collection : transactions
{
"_id": "QH2yYgJyE8A1zKBAWTv_T0VmvceS5l7p15Lki_i2PwfGoV3kHzkeqa6yFFm5oLhwriF39bAl2b4wgSIkvwy-MA",
"rate": [
{
"user_id": ObjectId("58aeb5bd21b8ae596d3c9869"),
"rate": "4",
"option": "QUICK_BITE",
"message": "Good"
}
]
}
Second collection : users
{
"_id": ObjectId("58aeb5bd21b8ae596d3c9869"),
"username": "ravi",
"profile": {
"firstname": "Ravi",
"lastname": "Kumar",
"email": "ravi#gamil.com",
"phone_no": "",
"company_name": "gmail",
"image": ""
}
},
{
"_id": ObjectId("58c104da21b8aeac733c9869"),
"username": "",
"profile": {
"firstname": "lalit",
"lastname": "sharma",
"email": "lxyz#gmail.com",
"phone_no": "",
"company_name": ""
}
},
{
"_id": ObjectId("58c12afc21b8aef8553c9869"),
"username": "",
"profile": {
"firstname": "Aijaz",
"lastname": "Haidar",
"email": "jazhaidar#gmail.com",
"phone_no": "",
"company_name": "yahoo",
"image": ""
}
}
I want to join users collection with transactions collection so that i should get the users full profile detail in rate feild.
Output something like
{
"_id" : ObjectId("58c1200321b8ae2d413c98a5"),
"rate" : [
{
"rate" : "4",
"option" : "QUICK_BITE",
"message" : "Good",
"profile" : {
"firstname" : "Ravi",
"lastname" : "Kumar",
"email" : "ravi#gamil.com",
"phone_no" : "",
"company_name" : "gmail",
"image" : ""
}
}
]
}
Right now I'm merge both collections using $lookup in the following way:
db.transactions.aggregate([
{$lookup: {
from: "users",
localField: "rate.user_id",
foreignField: "_id",
as: "profile"
}}
]);
But above query is not working :(
This is working for me
db.transactions.aggregate([
{
$match: { "name": "The Mean Fiddler" }
},
{
$unwind: "$rate"
},
{
$lookup:
{
from: "users",
localField: "rate.user_id",
foreignField: "_id",
as: "userInfo"
}
},{$unwind:"$userInfo"},{$unwind:"$userInfo.profile"},
{$project:{
"_id":1,
"rate":[{
'rate':"$rate.rate",
'option':"$rate.option",
'message':"$rate.message",
'profile' : {
'firstname' : "$userInfo.profile.firstname",
'lastname' :"$userInfo.profile.lastname" ,
'email' : "$userInfo.profile.email",
'phone_no' : "$userInfo.profile.phone_no",
'company_name' : "$userInfo.profile.company_name",
'image' : "$userInfo.profile.image",
},
}]
}}
])
I know you can count how many elements are in a collection with
collection.find().count().
However, I was wondering how can I count a certain element inside the item inside the collection. For example I have four images inside a Documents like this:
"Documents":{
"1":"image.png",
"2":"Test.jpg",
"3":"Next.png"
}
I was wondering how I can count all the items in Documents? I have tried a few things but none of them are working. Can anyone help?
Example data:
{
"name": "Oran",
"username": "Oran.Hammes",
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/brandonflatsoda/128.jpg",
"email": "xxxxxx#hotmail.com",
"dob": "1953-03-21T17:40:17.020Z",
"phone": "364-846-1607",
"address": {
"street": "Schultz Stream",
"suite": "Suite 618",
"city": "North Muriel mouth",
"zipcode": "06447-1081",
"geo": {
"lat": "57.1844",
"lng": "-56.8890"
}
},
"website": "misty.net",
"company": {
"name": "Hettinger, Reilly and Stracke",
"catchPhrase": "Multi-tiered system-worthy database",
"bs": "best-of-breed evolve e-markets"
},
"Documents": [
{
"id": "1",
"name": "image.png",
},
{
"id": "2",
"name": "Test.jpg",
},
{
"id": "3",
"name": "Next.png"
}
]
}
After this comment I changed my document's structure and it looks like this:
{
"_id" : ObjectId("568703d08981f193cf343698"),
"name" : "Oran",
"username" : "Oran.Hammes",
"email" : "xxxxxxx#hotmail.com",
"dob" : "1953-03-21T17:40:17.020Z",
"phone" : "364-846-1607",
"company" : {
"name" : "Hettinger, Reilly and Stracke",
"catchPhrase" : "Multi-tiered system-worthy database",
"bs" : "best-of-breed evolve e-markets"
},
"Documents" : [
{
"id" : "1",
"name" : "image.png"
},
{
"id" : "2",
"name" : "Test.jpg"
},
{
"id" : "3",
"name" : "Next.png"
}
]
}
Generally speaking it's not a good idea to have dynamic keys in your documents. Your best bet in situation like this is mapReduce
var map = function() {
emit(this._id, Object.keys(this.Documents).length);
};
var reduce = function(key, values) {};
db.collection.mapReduce(map, reduce, { "out": { "inline": 1 } } )
Which yields:
{
"results" : [
{
"_id" : ObjectId("5686e2a98981f193cf343697"),
"value" : 3
}
],
"timeMillis" : 697,
"counts" : {
"input" : 1,
"emit" : 1,
"reduce" : 0,
"output" : 1
},
"ok" : 1
}
Definitely the best thing to do is to change your documents structure and make Documents an array of sub-documents so that the Documents field value looks like this:
"Documents": [
{
"id": "1",
"name": "image.png",
},
{
"id": "2",
"name": "Test.jpg",
},
{
"id": "3",
"name": "Next.png"
}
]
and use the .aggregate() method to $project your documents and return the number of elements in the "Documents" array using the $size operator
db.collections.aggregate([
{ "$project": { "count": { "$size": "$Documents" } } }
] )
Edit:
Problem solved, see below.
I have the following document:
db.clients.insert({
_id: ObjectId("524d720d8d3ea014a52e95bb"),
company: "Example",
logins: [
{
"name": "John Smith",
"username": "test",
"password": "eF9wnBEys0OzL5vmR/OHGCaekHiw/Miy+XvbDdayxeo=",
"email": "a#a.com",
"last": null,
"roles": ["CONFIG"]
},
{
"name": "Guest",
"username": "guest",
"password": "K/gYODb7XPo0erySvL276DyPi4+stPPK4jM3pJ8aaVg=",
"email": "a#a.com",
"last": null,
"roles": []
}
]
});
And now, I want to authenticate my clients, using this document. But, I don't want to retrieve every sub logins, I want only the one which match.
That's why I'm using an aggregate:
db.clients.aggregate(
{
"$project": {
"login": "$logins",
"_id": 0
}
},
{
"$unwind": "$login"
},
{
"$group": {
"_id": "$login.username",
"login": {
"$first": "$login"
}
}
},
{
"$match": {
"login.username": "test",
"login.password": "eF9wnBEys0OzL5vmR/OHGCaekHiw/Miy+XvbDdayxeo=",
}
}
);
Which works fine, giving me:
{
"result" : [
{
"_id" : "test",
"login" : {
"name" : "John Smith",
"username" : "test",
"password" : "eF9wnBEys0OzL5vmR/OHGCaekHiw/Miy+XvbDdayxeo=",
"email" : "a#a.com",
"last" : null,
"roles" : [
"CONFIG"
]
}
}
],
"ok" : 1
}
But now, the tricky part is that I would like to retrieve also the root document fields. Such as _id and company for example.
But no matter what I try, I can't manage to do it. Do you have a solution? :)
Edit:
Ok, in fact it wasn't that hard. I'm sorry!
db.clients.aggregate(
{
"$project": {
"login": "$logins",
"_id": "$_id",
"company": "$company"
}
},
{
"$unwind": "$login"
},
{
"$group": {
"_id": "$login.username",
"login": {
"$first": "$login"
},
"clientId": {
"$first": "$_id"
},
"company": {
"$first": "$company"
},
}
},
{
"$match": {
"login.username": "test",
"login.password": "eF9wnBEys0OzL5vmR/OHGCaekHiw/Miy+XvbDdayxeo=",
}
}
);
You can do this with a find and the $ positional projection operator as well:
db.clients.find({
"logins.username": "test",
"logins.password": "eF9wnBEys0OzL5vmR/OHGCaekHiw/Miy+XvbDdayxeo=",
}, {
"logins.$": 1,
"company": 1
})
The $ in the projection contains the index of the logins array element that was matched in the query.
Output:
{
"_id": ObjectId("524d720d8d3ea014a52e95bb"),
"company": "Example",
"logins": [
{
"name": "John Smith",
"username": "test",
"password": "eF9wnBEys0OzL5vmR/OHGCaekHiw/Miy+XvbDdayxeo=",
"email": "a#a.com",
"last": null,
"roles": [
"CONFIG"
]
}
]
}
A bit shorter variant:
db.clients.aggregate(
{$match:{"logins.username":"test"}},
{$unwind:"$logins"},
{$match:{"logins.username":"test","logins.password":"eF9wnBEys0OzL5vmR/OHGCaekHiw/Miy+XvbDdayxeo="}}
)
Output is:
{
"result" : [
{
"_id" : ObjectId("524d720d8d3ea014a52e95bb"),
"company" : "Example",
"logins" : {
"name" : "John Smith",
"username" : "test",
"password" : "eF9wnBEys0OzL5vmR/OHGCaekHiw/Miy+XvbDdayxeo=",
"email" : "a#a.com",
"last" : null,
"roles" : [
"CONFIG"
]
}
}
],
"ok" : 1
}