I have a User schema that looks like this:
{
"_id" : ObjectId("5f0cbcdf8363cd155c2570f5"),
"clients" : [
{
"clientName" : "Chabad of Closter",
"activeInvoice" : [
{
"clientName" : "Chabad of Closter",
"startTime" : "2020-07-16T03:06:19.102Z",
"endTime" : "2020-07-16T06:06:19.102Z",
"duration" : "3.00",
"rate" : "25",
"description" : "email",
"total" : "$75.00"
},
{
"clientName" : "Chabad of Closter",
"startTime" : "2020-07-20T18:49:45.300Z",
"endTime" : "2020-07-20T20:49:45.300Z",
"duration" : "2.00",
"rate" : "25",
"description" : "janitor",
"total" : "$50.00"
},
{
"clientName" : "Chabad of Closter",
"startTime" : "2020-07-20T08:02:04.795Z",
"endTime" : "2020-07-20T21:02:04.795Z",
"duration" : "13.00",
"rate" : "35",
"description" : "something",
"total" : "$455.00"
}
],
"pastInvoices" : []
},
{
"clientName" : "Chabad UC",
"activeInvoice" : [
{
"clientName" : "Chabad UC",
"startTime" : "2020-07-14T00:43:30.689Z",
"endTime" : "2020-07-14T03:43:30.689Z",
"duration" : "3.00",
"rate" : "25",
"description" : "website",
"total" : "$75.00"
},
{
"clientName" : "Chabad UC",
"startTime" : "2020-07-14T00:43:30.689Z",
"endTime" : "2020-07-14T03:43:30.689Z",
"duration" : "3.00",
"rate" : "25",
"description" : "website",
"total" : "$75.00"
},
{
"clientName" : "Chabad UC",
"startTime" : "2020-07-16T08:32:44.980Z",
"endTime" : "2020-07-16T08:32:44.980Z",
"duration" : "0.00",
"rate" : "25",
"description" : "something",
"total" : "$0.00"
},
{
"clientName" : "Chabad UC",
"startTime" : "2020-07-20T20:22:27.399Z",
"endTime" : "2020-07-20T20:22:27.399Z",
"duration" : "0.00",
"rate" : 0,
"description" : "",
"total" : "$0.00"
}
],
"pastInvoices" : []
},
{
"clientName" : "Chabad Mobile",
"activeInvoice" : [
{
"clientName" : "Chabad Mobile",
"startTime" : "2020-07-14T04:05:18.084Z",
"endTime" : "2020-07-14T06:05:18.084Z",
"duration" : "2.00",
"rate" : "25",
"description" : "Fema grant",
"total" : "$50.00"
},
{
"clientName" : "Chabad UC",
"startTime" : "2020-07-16T04:56:51.451Z",
"endTime" : "2020-07-16T05:56:51.451Z",
"duration" : "1.00",
"rate" : "25",
"description" : "grants",
"total" : "$25.00"
},
{
"clientName" : "Chabad of Closter",
"startTime" : "2020-07-16T03:56:51.451Z",
"endTime" : "2020-07-16T05:56:51.451Z",
"duration" : "2.00",
"rate" : "26",
"description" : "grants",
"total" : "$52.00"
},
{
"clientName" : "Chabad Mobile",
"startTime" : "2020-07-15T18:51:00.000Z",
"endTime" : "2020-07-16T08:09:20.001Z",
"duration" : "13.31",
"rate" : "22",
"description" : "website",
"total" : "$292.82"
}
],
"pastInvoices" : []
}
],
"username" : "test50#test.com",
"password" : "************************************",
"firstName" : "John",
"__v" : 0
}
I'm trying to query the "clients" array with a value from the "clientName" property.
app.get("/closeinvoice", function(req, res){
// gets the id for the document
const id = req.user._id;
// gets the value of "clientName" for the query
const c = req.query.client;
User.find({_id: id, "clients.clientName": c}, function(err, foundDoc) {
if (err) {
console.log(err)
} else {
console.log(foundDoc);
}
})
})
Each time I do this, MongoDB returns the entire document. I need it to return only one object from the nested array. I'm also wondering if I could be using a different method from the Mongoose API. I would prefer to use "findByID" but I'm not sure if you can for this type of query.
You can take advantage of the $ (projection) operator which returns the first matching element from an array (based on corresponding `$elemMatch):
User.find({ _id: id, clients: { $elemMatch: { clientName: c }}}, { "clients.$": 1}, function(err, foundDoc) { ... })
Mongo Playground
Related
I am having certain issue with querying mongodb using mongoose, but unable to find my required output. Below is the data I am looking for the solution.
I am trying to find with two params here one is location and second is type
{
"_id" : ObjectId("5f04dcf8e123292518a863ae"),
"location" : "Australia",
"name" : "June Bill",
"filters" : [
{
"_id" : ObjectId("5f047efe9fc7ad000f44f990"),
"name" : "Q1",
"type" : "Platinum",
"conditions" : [
{
"And" : [
{
"_id" : "objectid",
"field" : "location",
"value" : "Australia",
"operator" : "equal"
},
{
"_id" : "objectid",
"field" : "name",
"value" : "admin",
"operator" : "equal"
}
]
}
]
},
{
"_id" : ObjectId("5f04d51c0ce40120bbb7dc6e"),
"name" : "Q2",
"type" : "Gold",
"conditions" : [
{
"_id" : ObjectId("5f04d51c0ce40120bbb7dc6f"),
"field" : "ocation",
"value" : "Australia",
"operator" : "equal"
},
{
"_id" : ObjectId("5f04d51c0ce40120bbb7dc70"),
"field" : "start_date",
"value" : "2020-06-01T00 3A00",
"operator" : "equal"
},
]
}
],
"__v" : 0
},
{
"_id" : ObjectId("5f04dcf8e123292518a863ae"),
"location" : "Brazil",
"name" : "June Bill",
"filters" : [
{
"_id" : ObjectId("5f047efe9fc7ad000f44f990"),
"name" : "Q1",
"type" : "Silver",
"conditions" : [
{
"And" : [
{
"_id" : "objectid",
"field" : "location",
"value" : "Australia",
"operator" : "equal"
},
{
"_id" : "objectid",
"field" : "name",
"value" : "admin",
"operator" : "equal"
}
]
}
]
},
{
"_id" : ObjectId("5f04d51c0ce40120bbb7dc6e"),
"name" : "Q2",
"type" : "Gold",
"conditions" : [
{
"_id" : ObjectId("5f04d51c0ce40120bbb7dc6f"),
"field" : "location",
"value" : "Australia",
"operator" : "equal"
},
{
"_id" : ObjectId("5f04d51c0ce40120bbb7dc70"),
"field" : "start_date",
"value" : "2020-06-01T00 3A00",
"operator" : "equal"
},
]
}
],
"__v" : 0
}
here I am trying to find with location and in filters with its type
How Can i do this in mongoose?
I tried
Model.find({'location': 'Brazil', 'filters':{ "$in" : ["Silver"]} });
But it didn't work, Can any one help me achieving actual result?
You can use the . to query the embedded filed or if you want to match multiple fields you can use $elemMatch
db.collection.find({
"location": "Brazil",
"filters.type": {
"$in": [
"Silver"
]
}
},
{
"filters.$": 1
})
MongoDB Playground
If you want to filter out the matched result you can use $ operator in projection
Use this way:
db.collection.find({
"location": "Brazil",
"filters.type": "Silver"
})
MongoDb Playground
The data :
{
"_id" : ObjectId("5da6ea7228cc5e07b48173b5"),
"name" : "Joshi",
"email" : "joshiga#gmail.com",
"password" : "4emc8122",
"phone" : "60000000001",
"myAddresses" : [
{
"_id" : ObjectId("5da6eb511e21bf07ce33b868"),
"address" : "Office",
"firstName" : "joshi",
"lastName" : "g",
"country" : "India",
"city" : "VISAKHAPATNAM",
"province" : "Andhra Pradesh",
"postalCode" : 521344,
"phoneNumber" : 8100000006.0,
"address1" : "D.no:12,",
"address2" : "santhi nagar, gurudwara"
},
{
"_id" : ObjectId("5da6ec5e20a5db07da27fbc6"),
"address" : "Home",
"firstName" : "joshi",
"lastName" : "g",
"country" : "India",
"city" : "Vijayawada",
"province" : "Andhra Pradesh",
"postalCode" : 521333,
"phoneNumber" : 8000000006.0,
"address1" : "D.no:11-41,",
"address2" : "main road, kalidindi"
}
],
"__v" : 0
}
You can use the following:
CollectionName.update({'myAddresses._id': "Your ID"}, {'$set': {
'myAddresses.$. address': 'updated Address'
}}, function(err) { ...
ModelName.update({
"_id": req.params.id,
"myAddresses": {
"$elemMatch": {
"_id": req.params.addressId
}
}
}, {
$set: {
"myAddresses.$.address": req.body.address,
"myAddresses.$.firstName": firstName,
//add all fields
}
})
I have one collection called "location". in this collection all child and parent collection are stores. now I want to create a query who returns me parent to child spaces separated string.
Collection
businessId: { type: mongoose.Schema.Types.ObjectId, ref: 'admin' },
parentId: { type: mongoose.Schema.Types.ObjectId, ref: 'location' },
name: { type: String },
image: { type: String },
imageManipulation: { type: String },
locationColor: [{ range: { type: String }, color: { type: String } }],
area: {},
settings: {},
status: { type: String, enum: [0, 1], default: 1 },
isChild: { type: String, enum: [0, 1] },
parentPosition: { type: String }
In the above collection, you can see parentId field. if the location is a child then it have parentId. if the location is a parent then parentId will null. parent location can N level child location.
Collection Data
[{
"_id" : ObjectId("5cee1002a01ad50f5c222982"),
"status" : "1",
"name" : "Ground Floor",
"settings" : {
"zoom" : "0",
"positionX" : "0",
"positionY" : "0",
"width" : "498",
"height" : "498"
},
"image" : "1559105538977.jpg",
"businessId" : ObjectId("5cbd61dc3b56b902284ea388"),
"locationColor" : [],
"updatedAt" : ISODate("2019-05-29T04:52:18.999Z"),
"createdAt" : ISODate("2019-05-29T04:52:18.999Z"),
"__v" : 0
},
{
"_id" : ObjectId("5cee103ca01ad50f5c222983"),
"status" : "1",
"name" : "Kitchen",
"settings" : {
"zoom" : "0",
"positionX" : "0",
"positionY" : "0",
"width" : "498",
"height" : "498"
},
"area" : "{\"type\":3,\"points\":[{\"x\":20,\"y\":178},{\"x\":19,\"y\":75},{\"x\":56,\"y\":71},{\"x\":57,\"y\":52},{\"x\":80,\"y\":18},{\"x\":138,\"y\":17},{\"x\":165,\"y\":52},{\"x\":165,\"y\":94},{\"x\":174,\"y\":96},{\"x\":173,\"y\":179}],\"fill\":\"rgba(178,40,40,0.58)\"}",
"parentId" : ObjectId("5cee1002a01ad50f5c222982"),
"image" : "1559105596975.jpg",
"businessId" : ObjectId("5cbd61dc3b56b902284ea388"),
"locationColor" : [],
"updatedAt" : ISODate("2019-05-29T04:53:16.990Z"),
"createdAt" : ISODate("2019-05-29T04:53:16.990Z"),
"__v" : 0
},
{
"_id" : ObjectId("5cee1078a01ad50f5c222984"),
"status" : "1",
"name" : "Cbot",
"settings" : {
"zoom" : "0",
"positionX" : "0",
"positionY" : "0",
"width" : "498",
"height" : "498"
},
"area" : "{\"type\":3,\"points\":[{\"x\":20,\"y\":311},{\"x\":17,\"y\":59},{\"x\":84,\"y\":58},{\"x\":88,\"y\":312}],\"fill\":\"rgba(20,205,123,0.67)\"}",
"parentId" : ObjectId("5cee103ca01ad50f5c222983"),
"image" : "1559105656049.jpg",
"businessId" : ObjectId("5cbd61dc3b56b902284ea388"),
"locationColor" : [],
"updatedAt" : ISODate("2019-05-29T04:54:16.070Z"),
"createdAt" : ISODate("2019-05-29T04:54:16.070Z"),
"__v" : 0
},
{
"_id" : ObjectId("5cee10c1a01ad50f5c222985"),
"status" : "1",
"name" : "Drower 1",
"settings" : {
"zoom" : "5",
"positionX" : "470",
"positionY" : "70",
"width" : "498",
"height" : "498"
},
"area" : "{\"type\":3,\"points\":[{\"x\":21,\"y\":102},{\"x\":81,\"y\":104},{\"x\":79,\"y\":43},{\"x\":21,\"y\":43}],\"fill\":\"rgba(16,77,193,0.5)\"}",
"parentId" : ObjectId("5cee1078a01ad50f5c222984"),
"image" : "1559105729881.jpg",
"businessId" : ObjectId("5cbd61dc3b56b902284ea388"),
"locationColor" : [],
"updatedAt" : ISODate("2019-05-29T04:55:29.901Z"),
"createdAt" : ISODate("2019-05-29T04:55:29.901Z"),
"__v" : 0
},
{
"_id" : ObjectId("5cee110ea01ad50f5c222986"),
"status" : "1",
"name" : "Drawer 2",
"settings" : {
"zoom" : "5",
"positionX" : "484",
"positionY" : "103",
"width" : "498",
"height" : "498"
},
"area" : "{\"type\":1,\"coordinates\":{\"x\":23,\"y\":125,\"width\":58,\"height\":56},\"points\":[{\"x\":23,\"y\":125},{\"x\":81,\"y\":181}],\"fill\":\"rgba(117,37,109,0.74)\"}",
"parentId" : ObjectId("5cee1078a01ad50f5c222984"),
"image" : "1559105806551.jpg",
"businessId" : ObjectId("5cbd61dc3b56b902284ea388"),
"locationColor" : [],
"updatedAt" : ISODate("2019-05-29T04:56:46.574Z"),
"createdAt" : ISODate("2019-05-29T04:56:46.574Z"),
"__v" : 0
},
{
"_id" : ObjectId("5cee1148a01ad50f5c222987"),
"status" : "1",
"name" : "Drawer 3",
"settings" : {
"zoom" : "5",
"positionX" : "477",
"positionY" : "94",
"width" : "498",
"height" : "498"
},
"area" : "{\"type\":3,\"points\":[{\"x\":22,\"y\":205},{\"x\":20,\"y\":290},{\"x\":84,\"y\":288},{\"x\":85,\"y\":205}],\"fill\":\"rgba(164,108,54,0.57)\"}",
"parentId" : ObjectId("5cee1078a01ad50f5c222984"),
"image" : "1559105864947.jpg",
"businessId" : ObjectId("5cbd61dc3b56b902284ea388"),
"locationColor" : [],
"updatedAt" : ISODate("2019-05-29T04:57:44.972Z"),
"createdAt" : ISODate("2019-05-29T04:57:44.972Z"),
"__v" : 0
},
{
"_id" : ObjectId("5cee5e683b9f67a9f501f818"),
"status" : "1",
"name" : "Washroom",
"settings" : {
"zoom" : "5",
"positionX" : "477",
"positionY" : "94",
"width" : "498",
"height" : "498"
},
"area" : "{\"type\":3,\"points\":[{\"x\":22,\"y\":205},{\"x\":20,\"y\":290},{\"x\":84,\"y\":288},{\"x\":85,\"y\":205}],\"fill\":\"rgba(164,108,54,0.57)\"}",
"parentId" : ObjectId("5cee1002a01ad50f5c222982"),
"image" : "1559105864947.jpg",
"businessId" : ObjectId("5cbd61dc3b56b902284ea388"),
"locationColor" : [],
"updatedAt" : ISODate("2019-05-29T04:57:44.972Z"),
"createdAt" : ISODate("2019-05-29T04:57:44.972Z"),
"__v" : 0
},
{
"_id" : ObjectId("5cee5f593b9f67a9f501fa01"),
"status" : "1",
"name" : "Third Floor",
"settings" : {
"zoom" : "0",
"positionX" : "0",
"positionY" : "0",
"width" : "498",
"height" : "498"
},
"image" : "1559105538977123.jpg",
"businessId" : ObjectId("5cbd61dc3b56b902284ea388"),
"locationColor" : [],
"updatedAt" : ISODate("2019-05-29T04:52:18.999Z"),
"createdAt" : ISODate("2019-05-29T04:52:18.999Z"),
"__v" : 0
}]
Expected result in JSON
[
{
"_id": "5cee1002a01ad50f5c222982",
"name": "Ground Floor"
},
{
"_id": "5cee103ca01ad50f5c222983",
"name": " Kitchen"
},
{
"_id": "5cee1078a01ad50f5c222984",
"name": " Cbot"
},
{
"_id": "5cee110ea01ad50f5c222986",
"name": " Drawer 2"
},
{
"_id": "5cee1148a01ad50f5c222987",
"name": " Drawer 3"
},
{
"_id": "5cee10c1a01ad50f5c222985",
"name": " Drower 1"
},
{
"_id": "5cee5e683b9f67a9f501f818",
"name": " Washroom"
},
{
"_id": "5cee5f593b9f67a9f501fa01",
"name": "Third Floor"
}
]
I do not think you should let mongodb take care of name formatting. So my solution is about finding how many spaces a certain name needs before, so that js can deal with formatting. This is the query:
db.collection.aggregate([
{
$graphLookup: {
from: "collection",
startWith: "$parentId",
connectFromField: "parentId",
connectToField: "_id",
as: "hierarchy"
}
},
{
$project: {
"_id": 1,
"name": 1,
"hierarchy_size": { $size: "$hierarchy" }
}
}
]);
With the $graphLookup, the db is building an in memory graph of edges between connectFromField and connectToField. From the graph you only need the depth of your hierarchy, so I computed hierarchy_size. This is the output:
/* 1 */
{
"_id" : ObjectId("5cee1002a01ad50f5c222982"),
"name" : "Ground Floor",
"hierarchy_size" : 0
}
/* 2 */
{
"_id" : ObjectId("5cee103ca01ad50f5c222983"),
"name" : "Kitchen",
"hierarchy_size" : 1
}
/* 3 */
{
"_id" : ObjectId("5cee1078a01ad50f5c222984"),
"name" : "Cbot",
"hierarchy_size" : 2
}
/* 4 */
{
"_id" : ObjectId("5cee10c1a01ad50f5c222985"),
"name" : "Drower 1",
"hierarchy_size" : 3
}
/* 5 */
{
"_id" : ObjectId("5cee110ea01ad50f5c222986"),
"name" : "Drawer 2",
"hierarchy_size" : 3
}
/* 6 */
{
"_id" : ObjectId("5cee1148a01ad50f5c222987"),
"name" : "Drawer 3",
"hierarchy_size" : 3
}
/* 7 */
{
"_id" : ObjectId("5cee5e683b9f67a9f501f818"),
"name" : "Washroom",
"hierarchy_size" : 1
}
/* 8 */
{
"_id" : ObjectId("5cee5f593b9f67a9f501fa01"),
"name" : "Third Floor",
"hierarchy_size" : 0
}
The only problem here might be query performances, but that depends on how much data you need to process. Also consider the memory limit.
I need a query for:
whose userids are : "userId" : "111b/c", "userId" : "111a". based on the user ids how many are $eq:light_pad:20 with them i need userId:111b/c-max date,userId:111a-max date
DB data
{ "_id" : ObjectId("5a7c1d167826eaca4b4e4398"), "firstName" : "varun", "secName" : "raju", "userId" : "111a", "light_pad" : "20", "lights" : "on", "CREATE_DATE" : ISODate("2018-05-08T03:12:00Z"), "Department" : "Computer Science and Engg", "Percentage" : "76%", "Address" : { "Street" : "Burkit Road", "City" : "chennai", "State" : "Tamil Nadu" }, "Gender" : "Male" }
{ "_id" : ObjectId("5a7c1db77826eaca4b4e4399"), "firstName" : "raju", "secName" : "rani", "userId" : "111a", "light_pad" : "40", "lights" : "off", "CREATE_DATE" : ISODate("2017-04-08T03:12:00Z"), "Department" : "Computer Science and Engg", "Percentage" : "86%", "Address" : { "Street" : "Burkit Road", "City" : "chennai", "State" : "Tamil Nadu" }, "Gender" : "female" }
{ "_id" : ObjectId("5a7c1e707826eaca4b4e439b"), "firstName" : "ranga", "secName" : "mahesh", "userId" : "111a", "light_pad" : "26", "lights" : "on", "CREATE_DATE" : ISODate("2012-04-08T03:12:00Z"), "Department" : "Computer Science and Engg", "Percentage" : "7%", "Address" : { "Street" : "Burkit ", "City" : "vizag", "State" : "Tamil Nadu" }, "Gender" : "female" }
{ "_id" : ObjectId("5a7c1f5d7826eaca4b4e439d"), "firstName" : "kalu", "secName" : "ramana", "userId" : "111b/c", "light_pad" : "25", "lights" : "off", "CREATE_DATE" : ISODate("2014-06-08T03:12:00Z"), "Department" : "maths", "Percentage" : "46%", "Address" : { "Street" : "Burkit ", "City" : "bhimavaram", "State" : "Tamil Nadu" }, "Gender" : "male" }
{ "_id" : ObjectId("5a7c1fb37826eaca4b4e439e"), "firstName" : "praveen", "secName" : "pani", "userId" : "111b/c", "light_pad" : "52", "lights" : "on", "CREATE_DATE" : ISODate("2016-06-08T03:12:00Z"), "Department" : "maths", "Percentage" : "36%", "Address" : { "Street" : "vin ", "City" : "palakoderu", "State" : "Tamil Nadu" }, "Gender" : "male" }
{ "_id" : ObjectId("5a7c20057826eaca4b4e439f"), "firstName" : "vani", "secName" : "karun", "userId" : "111b/c", "light_pad" : "52", "lights" : "on", "CREATE_DATE" : ISODate("2013-06-08T03:12:00Z"), "Department" : "maths", "Percentage" : "76%", "Address" : { "Street" : "bali ", "City" : "srikakulam", "State" : "Tamil Nadu" }, "Gender" : "male" }
Any answer will be appreciated
Thanks in advance.
I don't understand your question properly, but I have a solution that could be related to your question. I hope it will help you.
db.test.aggregate([{
$match: {
_id: {
$in: [ObjectId("5a7c1d167826eaca4b4e4398"),
ObjectId("5a7c1db77826eaca4b4e4399")]
},
light_pad: {
$eq: "20"
}
}
}]);
It will gives the given result:
{
"_id" : ObjectId("5a7c1d167826eaca4b4e4398"),
"firstName" : "varun",
"secName" : "raju",
"userId" : "111a",
"light_pad" : "20",
"lights" : "on",
"CREATE_DATE" : ISODate("2018-05-08T03:12:00.000Z"),
"Department" : "Computer Science and Engg",
"Percentage" : "76%",
"Address" : {
"Street" : "Burkit Road",
"City" : "chennai",
"State" : "Tamil Nadu"
},
"Gender" : "Male"
}
Hello This query is running fine for me I want to add other arrays as well like contact and I want separate count for them. If I add contact it add the result in count P.S : I used array name with $sum it start showing me zero count
return Company.aggregate(
{"$unwind":"$agreement"},
{"$unwind":"$contact"},
{"$unwind":"$companySite"},
{ $group: { _id: {
"Organization": "$orgId",
"Company": "$name"
}, "count": { $sum: 1 } } },{
"$project": {
"_id": 0,
"Company": "$_id.Company",
"Organization":"$_id.Organization",
"Count": "$count"
}
})
expected output
"Company": "Multi-Metal Manufacturing",
"Organization": "1",
"AgreementCount": 1,
"ContactCount" : 4
"ABC Count": 5
Sample Document is :
{
"_id" : ObjectId("57c6a97a90c933a2d54117dc"),
"ITBCompanyId" : 1034,
"updatedAt" : ISODate("2016-08-31T12:47:03.679Z"),
"createdAt" : ISODate("2016-08-31T09:55:06.217Z"),
"identifier" : "INL10",
"name" : "Inline Data Systems",
"addressLine1" : "7 Park Place",
"addressLine2" : "Ste D",
"city" : "Swansea",
"orgId" : "1",
"deletedAt" : null,
"_info" : {
"lastUpdated" : ISODate("2016-02-10T21:22:15.000Z"),
"updatedBy" : "Clarissa"
},
"whois" : [],
"configuration" : [],
"contact" : [
{
"email" : "justin#inlinedatasystems.com",
"mobileGuid" : "d8852942-8f5a-406f-a646-a5f8697f7885",
"presence" : null,
"gender" : null,
"title" : null,
"country" : null,
"zip" : null,
"state" : null,
"city" : null,
"addressLine2" : null,
"addressLine1" : null,
"lastName" : "Wilkerson",
"firstName" : "Justin",
"id" : 191,
"_id" : ObjectId("57c6abdfb966968130b1671c"),
"communicationItems" : [],
"customFields" : null,
"company" : {
"name" : "Inline Data Systems",
"id" : "19331"
},
"relationship" : {
"name" : null,
"id" : 0
}
}
],
"agreement" : [
{
"periodType" : null,
"billAmount" : "0",
"billTermsId" : 12,
"billOneTimeFlag" : false,
"billCycleId" : "2",
"expiredDays" : "0"
},
{
"id" : "40",
"name" : "Managed Hosted Server Agreement",
"billAmount" : "0",
"periodType" : null,
"_id" : ObjectId("57c6ab96b966968130b16616"),
"_info" : {
"lastUpdated" : ISODate("2014-10-03T14:25:42.000Z"),
"updatedBy" : "ali "
},
"contact" : {
"id" : "191",
"name" : "Justin Wilkerson"
},
"agreementType" : {
"id" : "33",
"name" : "HDCloud - Hosted Server"
}
},
{
"id" : "41",
"name" : "Managed Backup Agreement",
"parentAgreementId" : "42",
"customerPO" : ""
}
],
"companySite" : [
{
"id" : 1037,
"name" : "Main",
"city" : "Swansea",
"state" : "IL",
"zip" : "62226",
}
]