How can store the query mongoose result from an aggregate function into a variable and use it in other functions.
var rdvs= Rendezvous.find()
var emps =Employer.find();
console.log(rdvs)
console.log(emps)
this code display just query generated
Query {
_mongooseOptions: {},
mongooseCollection:
NativeCollection {
collection: Collection { s: [Object] },
opts: { bufferCommands: true, capped: false },
name: 'rendezvous',
collectionName: 'rendezvous',
conn:
NativeConnection {
base: [Object],
collections: [Object],
models: [Object],
config: [Object],
replica: false,
hosts: null,
host: 'localhost',
port: 27017,
user: undefined,
pass: undefined,
name: 'prise-rdv',
options: [Object],
otherDbs: [],
_readyState: 1,
_closeCalled: false,
_hasOpened: true,
_listening: false,
db: [Object],
_events: [Object],
_eventsCount: 3 },
queue: [],
buffer: false,
emitter:
EventEmitter {
domain: null,
_events: {},
_eventsCount: 0,
_maxListeners: undefined } },
model:
{ [Function: model]
hooks: Kareem { _pres: {}, _posts: {} },
base:
Mongoose {
connections: [Object],
plugins: [],
models: [Object],
modelSchemas: [Object],
options: [Object] },
modelName: 'Rendezvous',
model: [Function: model],
db:
NativeConnection {
base: [Object],
collections: [Object],
models: [Object],
config: [Object],
replica: false,
hosts: null,
host: 'localhost',
port: 27017,
user: undefined,
pass: undefined,
name: 'prise-rdv',
options: [Object],
otherDbs: [],
_readyState: 1,
_closeCalled: false,
_hasOpened: true,
_listening: false,
db: [Object],
_events: [Object],
_eventsCount: 3 },
discriminators: undefined,
load: [Function: load],
schema:
Schema {
obj: [Object],
paths: [Object],
subpaths: {},
virtuals: [Object],
singleNestedPaths: {},
nested: {},
inherits: {},
callQueue: [Object],
_indexes: [],
methods: {},
statics: [Object],
tree: [Object],
query: {},
childSchemas: [],
s: [Object],
options: [Object],
'$globalPluginsApplied': true },
collection:
NativeCollection {
collection: [Object],
opts: [Object],
name: 'rendezvous',
collectionName: 'rendezvous',
conn: [Object],
queue: [],
buffer: false,
emitter: [Object] },
Query: { [Function] base: [Object] },
'$__insertMany': [Function],
insertMany: [Function] },
schema:
Schema {
obj:
{ NameClient: [Object],
email: [Object],
tel: [Object],
service: [Object],
price: [Object],
date: [Object],
time: [Object],
idemploye: [Object],
createdAt: [Object],
updatedAt: [Object] },
paths:
{ NameClient: [Object],
email: [Object],
tel: [Object],
service: [Object],
price: [Object],
date: [Object],
time: [Object],
idemploye: [Object],
createdAt: [Object],
updatedAt: [Object],
_id: [Object],
__v: [Object] },
subpaths: {},
virtuals: { id: [Object] },
singleNestedPaths: {},
nested: {},
inherits: {},
callQueue: [ [Object], [Object], [Object], [Object] ],
_indexes: [],
methods: {},
statics: { load: [Function: load] },
tree:
{ NameClient: [Object],
email: [Object],
tel: [Object],
service: [Object],
price: [Object],
date: [Object],
time: [Object],
idemploye: [Object],
createdAt: [Object],
updatedAt: [Object],
_id: [Object],
id: [Object],
__v: [Function: Number] },
query: {},
childSchemas: [],
s: { hooks: [Object], kareemHooks: [Object] },
options:
{ retainKeyOrder: false,
typeKey: 'type',
id: true,
noVirtualId: false,
_id: true,
noId: false,
validateBeforeSave: true,
read: null,
shardKey: null,
autoIndex: null,
minimize: true,
discriminatorKey: '__t',
versionKey: '__v',
capped: false,
bufferCommands: true,
strict: true,
pluralization: true },
'$globalPluginsApplied': true },
op: 'find',
options: { retainKeyOrder: false },
_conditions: {},
_fields: undefined,
_update: undefined,
_path: undefined,
_distinct: undefined,
_collection:
NodeCollection {
collection:
NativeCollection {
collection: [Object],
opts: [Object],
name: 'rendezvous',
collectionName: 'rendezvous',
conn: [Object],
queue: [],
buffer: false,
emitter: [Object] },
collectionName: 'rendezvous' },
_traceFunction: undefined,
_castError: null,
_count: [Function],
_execUpdate: [Function],
_find: [Function],
_findOne: [Function],
_findOneAndRemove: [Function],
_findOneAndUpdate: [Function],
_replaceOne: [Function],
_updateMany: [Function],
_updateOne: [Function] }
Query {
_mongooseOptions: {},
mongooseCollection:
NativeCollection {
collection: Collection { s: [Object] },
opts: { bufferCommands: true, capped: false },
name: 'employers',
collectionName: 'employers',
conn:
NativeConnection {
base: [Object],
collections: [Object],
models: [Object],
config: [Object],
replica: false,
hosts: null,
host: 'localhost',
port: 27017,
user: undefined,
pass: undefined,
name: 'prise-rdv',
options: [Object],
otherDbs: [],
_readyState: 1,
_closeCalled: false,
_hasOpened: true,
_listening: false,
db: [Object],
_events: [Object],
_eventsCount: 3 },
queue: [],
buffer: false,
emitter:
EventEmitter {
domain: null,
_events: {},
_eventsCount: 0,
_maxListeners: undefined } },
model:
{ [Function: model]
hooks: Kareem { _pres: {}, _posts: {} },
base:
Mongoose {
connections: [Object],
plugins: [],
models: [Object],
modelSchemas: [Object],
options: [Object] },
modelName: 'Employer',
model: [Function: model],
db:
NativeConnection {
base: [Object],
collections: [Object],
models: [Object],
config: [Object],
replica: false,
hosts: null,
host: 'localhost',
port: 27017,
user: undefined,
pass: undefined,
name: 'prise-rdv',
options: [Object],
otherDbs: [],
_readyState: 1,
_closeCalled: false,
_hasOpened: true,
_listening: false,
db: [Object],
_events: [Object],
_eventsCount: 3 },
discriminators: undefined,
load: [Function: load],
schema:
Schema {
obj: [Object],
paths: [Object],
subpaths: {},
virtuals: [Object],
singleNestedPaths: {},
nested: {},
inherits: {},
callQueue: [Object],
_indexes: [],
methods: {},
statics: [Object],
tree: [Object],
query: {},
childSchemas: [Object],
s: [Object],
options: [Object],
'$globalPluginsApplied': true },
collection:
NativeCollection {
collection: [Object],
opts: [Object],
name: 'employers',
collectionName: 'employers',
conn: [Object],
queue: [],
buffer: false,
emitter: [Object] },
Query: { [Function] base: [Object] },
'$__insertMany': [Function],
insertMany: [Function] },
schema:
Schema {
obj:
{ phoneNumber: [Object],
email: [Object],
name: [Object],
idresponsable: [Object],
idsalon: [Object],
rate: [Object],
startTime: [Object],
endTime: [Object],
startRepos: [Object],
endRepos: [Object],
agenda: [Object],
createdAt: [Object],
updatedAt: [Object] },
paths:
{ phoneNumber: [Object],
email: [Object],
name: [Object],
idresponsable: [Object],
idsalon: [Object],
rate: [Object],
startTime: [Object],
endTime: [Object],
startRepos: [Object],
endRepos: [Object],
agenda: [Object],
createdAt: [Object],
updatedAt: [Object],
_id: [Object],
__v: [Object] },
subpaths: {},
virtuals: { id: [Object] },
singleNestedPaths: {},
nested: {},
inherits: {},
callQueue: [ [Object], [Object], [Object], [Object] ],
_indexes: [],
methods: {},
statics: { load: [Function: load] },
tree:
{ phoneNumber: [Object],
email: [Object],
name: [Object],
idresponsable: [Object],
idsalon: [Object],
rate: [Object],
startTime: [Object],
endTime: [Object],
startRepos: [Object],
endRepos: [Object],
agenda: [Object],
createdAt: [Object],
updatedAt: [Object],
_id: [Object],
id: [Object],
__v: [Function: Number] },
query: {},
childSchemas: [ [Object] ],
s: { hooks: [Object], kareemHooks: [Object] },
options:
{ retainKeyOrder: false,
typeKey: 'type',
id: true,
noVirtualId: false,
_id: true,
noId: false,
validateBeforeSave: true,
read: null,
shardKey: null,
autoIndex: null,
minimize: true,
discriminatorKey: '__t',
versionKey: '__v',
capped: false,
bufferCommands: true,
strict: true,
pluralization: true },
'$globalPluginsApplied': true },
op: 'find',
options: { retainKeyOrder: false },
_conditions: {},
_fields: undefined,
_update: undefined,
_path: undefined,
_distinct: undefined,
_collection:
NodeCollection {
collection:
NativeCollection {
collection: [Object],
opts: [Object],
name: 'employers',
collectionName: 'employers',
conn: [Object],
queue: [],
buffer: false,
emitter: [Object] },
collectionName: 'employers' },
_traceFunction: undefined,
_castError: null,
_count: [Function],
_execUpdate: [Function],
_find: [Function],
_findOne: [Function],
_findOneAndRemove: [Function],
_findOneAndUpdate: [Function],
_replaceOne: [Function],
_updateMany: [Function],
_updateOne: [Function] }
i want to store for example this in variable rdvs
rdvs=[{
"_id" : ObjectId("5932379e234e6602d817745c"),
"NameClient" : "meryem",
"tel" : "0610572084",
"service" : "massage",
"price" : NumberInt(50),
"date" : ISODate("2017-06-04T10:30:00.000+0000"),
"idemploye" : ObjectId("59319498efa50b137477a14b"),
"updatedAt" : ISODate("2017-06-03T04:14:22.469+0000"),
"createdAt" : ISODate("2017-06-03T04:14:22.469+0000"),
"email" : "meryem@gmail.com",
"__v" : NumberInt(0)
}
{
"_id" : ObjectId("593237fa80839a12747930be"),
"NameClient" : "rachida",
"tel" : "06105758964",
"service" : "serviceX",
"price" : NumberInt(60),
"date" : ISODate("2017-06-07T10:00:00.000+0000"),
"idemploye" : ObjectId("59319498efa50b137477a14b"),
"updatedAt" : ISODate("2017-06-03T04:15:54.929+0000"),
"createdAt" : ISODate("2017-06-03T04:15:54.929+0000"),
"email" : "rachida@gmail.com",
"__v" : NumberInt(0)
}
{
"_id" : ObjectId("593238232dbd6a02002633fe"),
"NameClient" : "imane",
"tel" : "06108566264",
"service" : "serviceY",
"price" : NumberInt(42),
"date" : ISODate("2017-06-07T10:00:00.000+0000"),
"idemploye" : ObjectId("59319498efa50b137477a14b"),
"updatedAt" : ISODate("2017-06-03T04:16:35.403+0000"),
"createdAt" : ISODate("2017-06-03T04:16:35.403+0000"),
"email" : "imane@gmail.com",
"__v" : NumberInt(0)
}
]
thank you for your help .
via ahmed chega
No comments:
Post a Comment