flow like the river

This commit is contained in:
root 2025-11-07 00:06:12 +01:00
commit 013fe673f3
42435 changed files with 5764238 additions and 0 deletions

View file

@ -0,0 +1,63 @@
const User = require('../models/User');
const Post = require('../models/Post');
const Node = require('../models/Node');
const Flow = require('../models/Flow');
const Project = require('../models/Project');
module.exports = {
users: async () => {
//... tu código existente para obtener usuarios
},
posts: async () => {
//... tu código existente para obtener posts
},
nodes: async () => {
try {
const nodes = await Node.find();
return nodes.map(node => {
return {
...node._doc,
_id: node._id.toString(),
flow: getFlow.bind(this, node._doc.flow)
};
});
} catch (err) {
throw err;
}
},
flows: async () => {
try {
const flows = await Flow.find();
return flows.map(flow => {
return {
...flow._doc,
_id: flow._id.toString(),
nodes: getNodes.bind(this, flow._doc.nodes),
project: getProject.bind(this, flow._doc.project)
};
});
} catch (err) {
throw err;
}
},
projects: async () => {
try {
const projects = await Project.find();
return projects.map(project => {
return {
...project._doc,
_id: project._id.toString(),
flows: getFlows.bind(this, project._doc.flows)
};
});
} catch (err) {
throw err;
}
},
}
// Aquí necesitarías implementar las funciones auxiliares getPosts, getUser, getFlow, getNodes, getFlows y getProject.

104
VISUALIZACION/graphql/schema.js Executable file
View file

@ -0,0 +1,104 @@
const { buildSchema } = require('graphql');
module.exports = buildSchema(`
type User {
_id: ID!
name: String!
email: String!
posts: [Post!]
}
type Post {
_id: ID!
title: String!
content: String!
creator: User!
}
type Node {
_id: ID!
name: String!
flow: Flow!
}
type Flow {
_id: ID!
nodes: [Node!]!
project: Project!
}
type Project {
_id: ID!
flows: [Flow!]!
}
type RootQuery {
users: [User!]!
posts: [Post!]!
nodes: [Node!]!
flows: [Flow!]!
projects: [Project!]!
}
schema {
query: RootQuery
}
`);
// export const newsData = [
// {
// "id": "1",
// "title": "BlackRock adquiere empresa de tecnología financiera",
// "shares": 3500
// },
// {
// "id": "2",
// "title": "BlackRock lanza nuevo fondo de inversión en energías renovables",
// "shares": 2900
// },
// {
// "id": "3",
// "title": "BlackRock reporta ganancias record en el último trimestre",
// "shares": 4000
// },
// {
// "id": "4",
// "title": "BlackRock lidera ronda de financiamiento en startup de inteligencia artificial",
// "shares": 2100
// },
// {
// "id": "5",
// "title": "CEO de BlackRock promueve inversiones sostenibles en cumbre global",
// "shares": 2600
// },
// {
// "id": "6",
// "title": "BlackRock apunta a mercados emergentes con nuevo producto de inversión",
// "shares": 2800
// },
// {
// "id": "7",
// "title": "BlackRock se compromete a reducir su huella de carbono en un 50% para 2030",
// "shares": 3500
// },
// {
// "id": "8",
// "title": "BlackRock lidera el mercado de ETFs con fuerte crecimiento en el último año",
// "shares": 3900
// },
// {
// "id": "9",
// "title": "BlackRock anuncia inversión millonaria en infraestructura de blockchain",
// "shares": 3300
// },
// {
// "id": "10",
// "title": "BlackRock apoya iniciativa de transparencia financiera en G20",
// "shares": 3000
// }
// ];