-
-
-
-
-
-
-
Parenting attributes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Clan attributes
-
-
-
-
diff --git a/familyark/app/public/templates/animal-show.html b/familyark/app/public/templates/animal-show.html
index 3857897..d599c56 100644
--- a/familyark/app/public/templates/animal-show.html
+++ b/familyark/app/public/templates/animal-show.html
@@ -1,6 +1,6 @@
Un dino
-
+
Aqui vendran graficas de cada atributo con el inicial y el actual, para que se pueda ver el crecimiento.
diff --git a/familyark/app/public/templates/home.html b/familyark/app/public/templates/home.html
index 396ae96..7c4e27b 100644
--- a/familyark/app/public/templates/home.html
+++ b/familyark/app/public/templates/home.html
@@ -2,10 +2,7 @@
Your app for your dinos.
Inventory, breeding and family.
-
+
Oficial Servers Mutiplier Status
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/familyark/app/server.js b/familyark/app/server.js
index 95f26c0..59e1c51 100644
--- a/familyark/app/server.js
+++ b/familyark/app/server.js
@@ -24,7 +24,7 @@ http.createServer(app)
router.get('/species', (req, res, next) => {
species.find({}, (err, result) => {
if (err) next(err)
- else res.json({ data: result, status: 'ok' })
+ else res.json({ data: result, status: 'ok' })
})
})
@@ -35,13 +35,36 @@ router.get('/animal', (req, res, next) => {
})
})
+router.get('/animal/childrens/:id', (req, res, next) => {
+ animal.find({ $or: [ { father: req.params.id }, { mother: req.params.id } ] }, (err, result) => {
+ if (err) next(err)
+ else res.json({ data: result, status: 'ok' })
+ })
+})
+
+router.get('/animal/parrents/:id', (req, res, next) => {
+ animal.find({ _id: req.params.id }, (err, result) => {
+ if (err) next(err)
+ else animal.find({ $or: [ { _id: result[0].father }, { _id: result[0].mother } ] }, (err, result2) => {
+ if (err) next(err)
+ else res.json({ data: result2, status: 'ok' })
+ })
+ })
+})
+
router.get('/animal/:id', (req, res, next) => {
animal.find({ _id: mongoose.Types.ObjectId(req.params.id) }, (err, result) => {
if (err) next(err)
- else res.json({ data: result, status: 'ok' })
+ else res.json({ data: result[0], status: 'ok' })
})
})
+router.get('/animal/:specie/:sex', (req, res, next) => {
+ animal.find({ specie: req.params.specie, sex: req.params.sex}, (err, result) => {
+ if (err) next(err)
+ else res.json({ data: result, status: 'ok' })
+ })
+})
router.post('/animal', (req, res, next) => {
let s1 = new animal(req.body)
@@ -76,6 +99,7 @@ router.get('/info', (req, res, next) => {
res.json(acc)
});
})
+
/*function recu(acc,item){
if(item.mather != null){
animal.find({ _id: mongoose.Types.ObjectId(item.mother) }, (err, result) => {
@@ -86,23 +110,23 @@ router.get('/info', (req, res, next) => {
};
*/
-router.get('/animal/tree/:id', (req, res, next) => {
-/* animal.find({ _id: mongoose.Types.ObjectId(req.params.id) }, (err, result) => {
- if (err) next(err)
- else res.json(recu([],result[0]))
- })
-*/
- animal.aggregate([{ $match: { _id: mongoose.Types.ObjectId(req.params.id) }},
- { $graphLookup: { from: 'animals', startWith: ['$father', '$mother'], connectFromField: 'mother', connectToField: '_id', as: 'ancestorsmother', maxDepth: 99, depthField: 'depth' }},
- { $graphLookup: { from: 'animals', startWith: ['$father', '$mother'], connectFromField: 'father', connectToField: '_id', as: 'ancestorsfather', maxDepth: 99, depthField: 'depth' }},
- { $graphLookup: { from: 'animals', startWith: '$_id', connectFromField: '_id', connectToField: 'mother', as: 'childrensmother', maxDepth: 99, depthField: 'depth' }},
- { $graphLookup: { from: 'animals', startWith: '$_id', connectFromField: '_id', connectToField: 'father', as: 'childrensfather', maxDepth: 99, depthField: 'depth' }},
- { $project: { 'name': 1, 'sex': 1, 'father': 1, 'mother': 1, ancestors: { $setUnion: ['$ancestorsmother', '$ancestorsfather'] }, childrens: { $setUnion: ['$childrensmother', '$childrensfather'] }}
- }]).allowDiskUse(true).exec((err, connections) => {
- if (err) next(err)
- else res.json(connections)
- })
-})
+// router.get('/animal/tree/:id', (req, res, next) => {
+// /* animal.find({ _id: mongoose.Types.ObjectId(req.params.id) }, (err, result) => {
+// if (err) next(err)
+// else res.json(recu([],result[0]))
+// })
+// */
+// animal.aggregate([{ $match: { _id: mongoose.Types.ObjectId(req.params.id) }},
+// { $graphLookup: { from: 'animals', startWith: ['$father', '$mother'], connectFromField: 'mother', connectToField: '_id', as: 'ancestorsmother', maxDepth: 99, depthField: 'depth' }},
+// { $graphLookup: { from: 'animals', startWith: ['$father', '$mother'], connectFromField: 'father', connectToField: '_id', as: 'ancestorsfather', maxDepth: 99, depthField: 'depth' }},
+// { $graphLookup: { from: 'animals', startWith: '$_id', connectFromField: '_id', connectToField: 'mother', as: 'childrensmother', maxDepth: 99, depthField: 'depth' }},
+// { $graphLookup: { from: 'animals', startWith: '$_id', connectFromField: '_id', connectToField: 'father', as: 'childrensfather', maxDepth: 99, depthField: 'depth' }},
+// { $project: { 'name': 1, 'sex': 1, 'father': 1, 'mother': 1, ancestors: { $setUnion: ['$ancestorsmother', '$ancestorsfather'] }, childrens: { $setUnion: ['$childrensmother', '$childrensfather'] }}
+// }]).allowDiskUse(true).exec((err, connections) => {
+// if (err) next(err)
+// else res.json(connections)
+// })
+// })
app.use(bodyParser.urlencoded({
extended: true