{"id":213,"date":"2018-08-06T12:23:46","date_gmt":"2018-08-06T19:23:46","guid":{"rendered":"https:\/\/rosolutions.com.mx\/blog\/?p=213"},"modified":"2018-10-09T12:18:15","modified_gmt":"2018-10-09T19:18:15","slug":"como-usar-un-orm-en-node-js","status":"publish","type":"post","link":"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/","title":{"rendered":"C\u00f3mo usar un ORM en Node.js"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">En este blog hablar\u00e9 un poco sobre los ORM\u2019s, sus beneficios (pros) y limitaciones (cons), que es Sequelize y c\u00f3mo usarlo.<\/span><\/p>\n<h2><a href=\"https:\/\/en.wikipedia.org\/wiki\/Object-relational_mapping\" target=\"_blank\" rel=\"noopener\"><b>Object-Relational Mapping<\/b><\/a><\/h2>\n<p><span style=\"font-weight: 400;\">Es una t\u00e9cnica para convertir datos entre el sistema de tipos del lenguaje de programaci\u00f3n y la base de datos. Como su nombre lo indica, esto va dirigido solamente a las base de datos relacional (SQL). Esto crea un efecto \u201cobjeto base de datos virtual\u201d sobre la base de datos relacional, este efecto es lo que nos permite manipular la base de datos a trav\u00e9s del c\u00f3digo. <\/span><\/p>\n<p><b>Object <\/b><span style=\"font-weight: 400;\">&#8211; Hace referencia al\/los objeto(s) que podemos usar en nuestro lenguaje.<\/span><\/p>\n<p><b>Relational <\/b><span style=\"font-weight: 400;\">&#8211; Hace referencia a nuestro Sistema Gestor de Base de Datos (MySQL, MSSQL, PostgreSQL).<\/span><\/p>\n<p><b>Mapping <\/b><span style=\"font-weight: 400;\">&#8211; Hace referencia a la conexi\u00f3n entre el los objetos y las tablas.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center;\"><b>tl;dr\u00a0<\/b>ORM es una t\u00e9cnica que nos permite hacer queries y manipular datos de la base de datos desde un lenguaje de programaci\u00f3n.<\/p>\n<p>&nbsp;<\/p>\n<h4><b>Pros<\/b><\/h4>\n<ul>\n<li><span style=\"font-weight: 400;\">Abstracto: Dise\u00f1o de una estructura o modelo aislado de la base de datos.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Portable: Te permite transportar la estructura de tu ORM a cualquier DBMS.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Anidaci\u00f3n de datos: En caso de que una tabla tenga una o varias relaciones con otras.<\/span><\/li>\n<\/ul>\n<h4><b>Cons<\/b><\/h4>\n<ul>\n<li><span style=\"font-weight: 400;\">Lento: Si se compara el tiempo de respuesta entre un raw query y un query hecho por objetos, raw query es mucho mas r\u00e1pido debido a que no existe una capa (mapping).<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Complejidad: Algunas veces necesitaremos hacer queries complejos, por suerte Sequelize te permite ejecutar raw queries.<\/span><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2><b>Que es Sequelize ?<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Sequelize es un ORM basado en promesas para Node.js. Soporta PostgreSQL, MySQL, SQLite y MSSQL, y entrega caracter\u00edsticas s\u00f3lidas de transacciones, relaciones entre tablas, mecanismos de migraciones y carga de datos, y m\u00e1s.<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><b>Porque decid\u00ed utilizar Sequelize ? <\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Sequelize maneja sus objetos como promesas, algo que va de la mano con el event loop de Node.js.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Ahora les mostrar\u00e9 c\u00f3mo crear y migrar tablas, cargar datos, y c\u00f3mo consultar estos datos. Si quieren checar el c\u00f3digo, pueden clonarlo desde <a href=\"https:\/\/github.com\/fob2257\/howto-sequelize\" target=\"_blank\" rel=\"noopener\">aqu\u00ed<\/a>.<\/span><\/p>\n<h4><b>Requerimientos<\/b><\/h4>\n<ul>\n<li><span style=\"font-weight: 400;\">Node.js 8.0+<\/span><\/li>\n<li><span style=\"font-weight: 400;\">MySQL 5.7+<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Primero instalaremos globalmente el m\u00f3dulo <a href=\"https:\/\/www.npmjs.com\/package\/sequelize-cli\" target=\"_blank\" rel=\"noopener\">sequelize-cli<\/a>:<\/span><\/p>\n<pre class=\"bash\" style=\"font-family: monospace;\">npm i <span style=\"color: #660033;\">-g<\/span> sequelize-cli<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Despu\u00e9s crearemos una carpeta donde contenga nuestra aplicaci\u00f3n, crearemos un archivo js e\u00a0instalaremos <a href=\"https:\/\/www.npmjs.com\/package\/sequelize\" target=\"_blank\" rel=\"noopener\">sequelize<\/a> y su dialecto (en este caso <a href=\"https:\/\/www.npmjs.com\/package\/mysql2\" target=\"_blank\" rel=\"noopener\">MySQL<\/a>):<\/span><\/p>\n<pre class=\"bash\" style=\"font-family: monospace;\"><span style=\"color: #c20cb9; font-weight: bold;\">mkdir<\/span> howto-sequelize <span style=\"color: #000000; font-weight: bold;\">&amp;&amp;<\/span> <span style=\"color: #7a0874; font-weight: bold;\">cd<\/span> howto-sequelize\r\n<span style=\"color: #c20cb9; font-weight: bold;\">touch<\/span> index.js\r\nnpm init <span style=\"color: #660033;\">-y<\/span>\r\nnpm i <span style=\"color: #660033;\">-S<\/span> sequelize mysql2<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Ahora tenemos que iniciar el proyecto con sequelize-cli:<\/span><\/p>\n<pre class=\"bash\" style=\"font-family: monospace;\">sequelize init<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">sequelize-cli nos cre\u00f3 una estructura base en la ra\u00edz de nuestro proyecto:<\/span><\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-227\" src=\"https:\/\/rosolutions.com.mx\/blog\/wp-content\/uploads\/2018\/08\/ayyy.png\" alt=\"\" width=\"288\" height=\"190\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Si revisamos el archivo <em>.\/config\/config.json<\/em>, vemos que tenemos 3 opciones de conexi\u00f3n a una base de datos, modifiquemos la opci\u00f3n \u201cdevelopment\u201d:<\/span><\/p>\n<pre class=\"javascript\" style=\"font-family: monospace;\"><span style=\"color: #3366cc;\">\"development\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #009900;\">{<\/span>\r\n    <span style=\"color: #3366cc;\">\"username\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">\"root\"<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #3366cc;\">\"password\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">\"tucontrase\u00f1a\"<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #3366cc;\">\"database\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">\"howto-sequelize\"<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #3366cc;\">\"host\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">\"127.0.0.1\"<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #3366cc;\">\"dialect\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">\"mysql\"<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #3366cc;\">\"operatorsAliases\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #003366; font-weight: bold;\">false<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #3366cc;\">\"dialectOptions\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #009900;\">{<\/span>\r\n      <span style=\"color: #3366cc;\">\"charset\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">\"utf8mb4\"<\/span>\r\n    <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #3366cc;\">\"logging\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #003366; font-weight: bold;\">true<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #3366cc;\">\"benchmark\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #003366; font-weight: bold;\">true<\/span>\r\n  <span style=\"color: #009900;\">}<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Ahora revisemos el archivo <em>.\/models\/index.js<\/em>. Este archivo tiene como funci\u00f3n crear una nueva instancia de Sequelize cada vez que sea llamado, y tiene como variable de entorno default a \u201cdevelopment\u201d, la cual utilizar\u00e1 la base de datos, host, usuario, contrase\u00f1a y opciones que acabamos de agregar.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Creemos nuestra base de datos con el siguiente comando:<\/span><\/p>\n<pre class=\"bash\" style=\"font-family: monospace;\">sequelize db:create<\/pre>\n<p>&nbsp;<\/p>\n<p>Muy bien! Ahora empecemos a crear nuestros modelos:<\/p>\n<pre class=\"bash\" style=\"font-family: monospace;\">sequelize model:generate <span style=\"color: #660033;\">--name<\/span> Usuario <span style=\"color: #660033;\">--attributes<\/span> nombre:string,apellidoP:string,apellidoM:string,email:string\r\n\u00a0\r\nsequelize model:generate <span style=\"color: #660033;\">--name<\/span> LenguajeP <span style=\"color: #660033;\">--attributes<\/span> nombre:string\r\n\u00a0\r\nsequelize model:generate <span style=\"color: #660033;\">--name<\/span> Usuario_LenguajeP <span style=\"color: #660033;\">--attributes<\/span>\r\nUsuarioId:integer,LenguajePId:integer\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Despu\u00e9s de crear nuestros modelos hay que hacer la relaci\u00f3n entre usuarios y lenguajes.<\/span><\/p>\n<p><em>.\/models\/usuario.js<\/em><\/p>\n<pre class=\"javascript\" style=\"font-family: monospace;\"><span style=\"color: #3366cc;\">'use strict'<\/span><span style=\"color: #339933;\">;<\/span>\r\nmodule.<span style=\"color: #660066;\">exports<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #009900;\">(<\/span>sequelize<span style=\"color: #339933;\">,<\/span> DataTypes<span style=\"color: #009900;\">)<\/span> <span style=\"color: #339933;\">=&gt;<\/span> <span style=\"color: #009900;\">{<\/span>\r\n  <span style=\"color: #000066; font-weight: bold;\">var<\/span> Usuario <span style=\"color: #339933;\">=<\/span> sequelize.<span style=\"color: #660066;\">define<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #3366cc;\">'Usuario'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">{<\/span>\r\n    nombre<span style=\"color: #339933;\">:<\/span> DataTypes.<span style=\"color: #660066;\">STRING<\/span><span style=\"color: #339933;\">,<\/span>\r\n    apellidoP<span style=\"color: #339933;\">:<\/span> DataTypes.<span style=\"color: #660066;\">STRING<\/span><span style=\"color: #339933;\">,<\/span>\r\n    apellidoM<span style=\"color: #339933;\">:<\/span> DataTypes.<span style=\"color: #660066;\">STRING<\/span><span style=\"color: #339933;\">,<\/span>\r\n    email<span style=\"color: #339933;\">:<\/span> DataTypes.<span style=\"color: #660066;\">STRING<\/span>\r\n  <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">{<\/span><span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n  Usuario.<span style=\"color: #660066;\">associate<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #000066; font-weight: bold;\">function<\/span><span style=\"color: #009900;\">(<\/span>models<span style=\"color: #009900;\">)<\/span> <span style=\"color: #009900;\">{<\/span>\r\n    <span style=\"color: #006600; font-style: italic;\">\/\/ associations can be defined here<\/span>\r\n    Usuario.<span style=\"color: #660066;\">belongsToMany<\/span><span style=\"color: #009900;\">(<\/span>models.<span style=\"color: #660066;\">LenguajeP<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">{<\/span>\r\n      through<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'Usuario_LenguajeP'<\/span><span style=\"color: #339933;\">,<\/span>\r\n      as<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'lenguajesProgramacion'<\/span><span style=\"color: #339933;\">,<\/span>\r\n      foreignKey<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'UsuarioId'<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span>\r\n  <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">;<\/span>\r\n  <span style=\"color: #000066; font-weight: bold;\">return<\/span> Usuario<span style=\"color: #339933;\">;<\/span>\r\n<span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">;<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Anal\u00edcemos esto, vemos que nuestro modelo Usuario ejecuta una \u00a0funci\u00f3n belongsToMany la cual apunta al modelo LenguajeP, en pocas palabras estamos indicando que un usuario puede pertenecer a varios lenguajes. En las opciones, <\/span><i><span style=\"font-weight: 400;\"><strong>through<\/strong> <\/span><\/i><span style=\"font-weight: 400;\">indica la tabla por la que tiene que cruzar para encontrar estas relaciones, <\/span><strong><i>as<\/i><\/strong><span style=\"font-weight: 400;\">, es opcional, es el nombre de la propiedad o key que nos entregar\u00e1 estas relaciones, \u00a0<\/span><i><span style=\"font-weight: 400;\"><strong>foreignKey<\/strong> <\/span><\/i><span style=\"font-weight: 400;\">marca por que columna queremos que busque estas relaciones.<\/span><\/p>\n<p><em><span style=\"font-weight: 400;\">.\/models\/lenguajep.js<\/span><\/em><\/p>\n<pre class=\"javascript\" style=\"font-family: monospace;\"><span style=\"color: #3366cc;\">'use strict'<\/span><span style=\"color: #339933;\">;<\/span>\r\nmodule.<span style=\"color: #660066;\">exports<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #009900;\">(<\/span>sequelize<span style=\"color: #339933;\">,<\/span> DataTypes<span style=\"color: #009900;\">)<\/span> <span style=\"color: #339933;\">=&gt;<\/span> <span style=\"color: #009900;\">{<\/span>\r\n  <span style=\"color: #000066; font-weight: bold;\">var<\/span> LenguajeP <span style=\"color: #339933;\">=<\/span> sequelize.<span style=\"color: #660066;\">define<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #3366cc;\">'LenguajeP'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">{<\/span>\r\n    nombre<span style=\"color: #339933;\">:<\/span> DataTypes.<span style=\"color: #660066;\">STRING<\/span>\r\n  <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">{<\/span><span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n  LenguajeP.<span style=\"color: #660066;\">associate<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #000066; font-weight: bold;\">function<\/span> <span style=\"color: #009900;\">(<\/span>models<span style=\"color: #009900;\">)<\/span> <span style=\"color: #009900;\">{<\/span>\r\n    <span style=\"color: #006600; font-style: italic;\">\/\/ associations can be defined here<\/span>\r\n    LenguajeP.<span style=\"color: #660066;\">belongsToMany<\/span><span style=\"color: #009900;\">(<\/span>models.<span style=\"color: #660066;\">Usuario<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">{<\/span>\r\n      through<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'Usuario_LenguajeP'<\/span><span style=\"color: #339933;\">,<\/span>\r\n      as<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'usuarios'<\/span><span style=\"color: #339933;\">,<\/span>\r\n      foreignKey<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'LenguajePId'<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span>\r\n  <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">;<\/span>\r\n  <span style=\"color: #000066; font-weight: bold;\">return<\/span> LenguajeP<span style=\"color: #339933;\">;<\/span>\r\n<span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">;<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Hacemos lo mismo con los lenguajes (LenguajeP), pero ahora apuntando al modelo Usuario.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Recordemos un poco lo que platicamos arriba, ORM trabaja sobre una capa que es el mapping (mapeo), estas relaciones s\u00f3lo se ver\u00e1n efectuadas en el proyecto, nos falta crear una migraci\u00f3n que afecte a la base de datos. Existen ORM\u2019s que revisan si has hecho cambios a tus modelos y crean nuevas migraciones a partir de estos cambios (Django ORM, peewee), en nuestro caso Sequelize no cuenta con eso, as\u00ed que nosotros crearemos nuestras migraciones:<\/span><\/p>\n<pre class=\"bash\" style=\"font-family: monospace;\">sequelize migration:generate <span style=\"color: #660033;\">--name<\/span> relation-many-to-many<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Esto nos gener\u00f3 un archivo nuevo con un esqueleto en nuestras migraciones, ahora tenemos que modificarlo:<\/span><\/p>\n<pre class=\"javascript\" style=\"font-family: monospace;\"><span style=\"color: #3366cc;\">'use strict'<\/span><span style=\"color: #339933;\">;<\/span>\r\n\u00a0\r\nmodule.<span style=\"color: #660066;\">exports<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #009900;\">{<\/span>\r\n  up<span style=\"color: #339933;\">:<\/span> <span style=\"color: #009900;\">(<\/span>queryInterface<span style=\"color: #339933;\">,<\/span> Sequelize<span style=\"color: #009900;\">)<\/span> <span style=\"color: #339933;\">=&gt;<\/span> <span style=\"color: #009900;\">{<\/span>\r\n   <span style=\"color: #000066; font-weight: bold;\">return<\/span> <span style=\"color: #009900;\">[<\/span>\r\n    queryInterface.<span style=\"color: #660066;\">addConstraint<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #3366cc;\">'Usuario_LenguajeP'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">[<\/span><span style=\"color: #3366cc;\">'UsuarioId'<\/span><span style=\"color: #009900;\">]<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">{<\/span>\r\n      type<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'FOREIGN KEY'<\/span><span style=\"color: #339933;\">,<\/span>\r\n      name<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'FK_UsuarioLenguajeP_Usuario_1'<\/span><span style=\"color: #339933;\">,<\/span>\r\n      references<span style=\"color: #339933;\">:<\/span> <span style=\"color: #009900;\">{<\/span>\r\n        table<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'Usuario'<\/span><span style=\"color: #339933;\">,<\/span>\r\n        field<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'id'<\/span><span style=\"color: #339933;\">,<\/span>\r\n      <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span>\r\n      onDelete<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'no action'<\/span><span style=\"color: #339933;\">,<\/span>\r\n      onUpdate<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'no action'<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n    queryInterface.<span style=\"color: #660066;\">addConstraint<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #3366cc;\">'Usuario_LenguajeP'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">[<\/span><span style=\"color: #3366cc;\">'LenguajePId'<\/span><span style=\"color: #009900;\">]<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">{<\/span>\r\n      type<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'FOREIGN KEY'<\/span><span style=\"color: #339933;\">,<\/span>\r\n      name<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'FK_UsuarioLenguajeP_LenguajeP_1'<\/span><span style=\"color: #339933;\">,<\/span>\r\n      references<span style=\"color: #339933;\">:<\/span> <span style=\"color: #009900;\">{<\/span>\r\n        table<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'LenguajeP'<\/span><span style=\"color: #339933;\">,<\/span>\r\n        field<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'id'<\/span><span style=\"color: #339933;\">,<\/span>\r\n      <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span>\r\n      onDelete<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'no action'<\/span><span style=\"color: #339933;\">,<\/span>\r\n      onUpdate<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'no action'<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n  <span style=\"color: #009900;\">]<\/span>\r\n  <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span>\r\n\u00a0\r\n  down<span style=\"color: #339933;\">:<\/span> <span style=\"color: #009900;\">(<\/span>queryInterface<span style=\"color: #339933;\">,<\/span> Sequelize<span style=\"color: #009900;\">)<\/span> <span style=\"color: #339933;\">=&gt;<\/span> <span style=\"color: #009900;\">{<\/span>\r\n   <span style=\"color: #000066; font-weight: bold;\">return<\/span> <span style=\"color: #009900;\">[<\/span>\r\n    queryInterface.<span style=\"color: #660066;\">removeConstraint<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #3366cc;\">'Usuario_LenguajeP'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #3366cc;\">'FK_UsuarioLenguajeP_Usuario_1'<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n    queryInterface.<span style=\"color: #660066;\">removeConstraint<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #3366cc;\">'Usuario_LenguajeP'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #3366cc;\">'FK_UsuarioLenguajeP_LenguajeP_1'<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n  <span style=\"color: #009900;\">]<\/span>\r\n  <span style=\"color: #009900;\">}<\/span>\r\n<span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">;<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Este archivo exporta un objeto con 2 propiedades, up y down. La propiedad up est\u00e1 encargada de entregar una promesa que altere los datos (crear tablas, relaciones, campos, cambiar tipos, etc), y la propiedad down hace lo contrario, revierte los cambios que se hayan efectuado en up.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Muy bien, ahora toca mi parte favorita, hay que correr los scripts de migraci\u00f3n con el siguiente comando:<\/span><\/p>\n<pre class=\"bash\" style=\"font-family: monospace;\">sequelize db:migrate<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">BOOM! Pero qu\u00e9 pas\u00f3?!?! Si leemos con atenci\u00f3n el error en la consola dice que no encuentra la tabla Usuario_LenguajeP en la base de datos, revisemos las tablas. Hay algo curioso, todas terminan con una \u201cs\u201d, esto es porque sequelize-cli maneja las tablas en plural por default, a\u00fan cuando en nuestras opciones tengamos <\/span><span style=\"font-weight: 400;\"><em>freezeTableName: true<\/em>, este caso lo pueden ver <a href=\"https:\/\/github.com\/sequelize\/sequelize\/issues\/8785\" target=\"_blank\" rel=\"noopener\">aqu\u00ed<\/a>.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Entonces solo nos falta cambiar el nombre de las <a href=\"https:\/\/raw.githubusercontent.com\/fob2257\/howto-sequelize\/master\/migrations\/20180804183246-relation-many-to-many.js\" target=\"_blank\" rel=\"noopener\">tablas a plural en relation-many-to-many<\/a> (<\/span>Usuario_LenguajePs, Usuarios, LenguajePs).<\/p>\n<div>\n<div><span style=\"font-weight: 400;\">Deshacemos las migraciones, volvemos a migrar y voil\u00e0:<\/span><\/div>\n<pre class=\"bash\" style=\"font-family: monospace;\">sequelize db:migrate:undo:all\r\nsequelize db:migrate<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" class=\"size-medium wp-image-245 aligncenter\" src=\"https:\/\/rosolutions.com.mx\/blog\/wp-content\/uploads\/2018\/08\/feelsgood-300x277.png\" alt=\"\" width=\"300\" height=\"277\" srcset=\"https:\/\/rosolutions.com.mx\/blog\/wp-content\/uploads\/2018\/08\/feelsgood-300x277.png 300w, https:\/\/rosolutions.com.mx\/blog\/wp-content\/uploads\/2018\/08\/feelsgood.png 659w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>Las migraciones fueron exitosas!\u00a0<span style=\"font-weight: 400;\">Ahora tenemos que poblar estas tablas, sequelize-cli utiliza las seeds (semillas). Vamos a crear 3 archivos seed:<\/span><\/p>\n<pre class=\"bash\" style=\"font-family: monospace;\">sequelize seed:generate <span style=\"color: #660033;\">--name<\/span> usuario\r\nsequelize seed:generate <span style=\"color: #660033;\">--name<\/span> lenguajep\r\nsequelize seed:generate <span style=\"color: #660033;\">--name<\/span> usuario_lenguajep\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Estas semillas est\u00e1n ubicadas en la carpeta<em> .\/seeders<\/em>, hay que poner los datos que deseamos cargar en la base de datos.<\/span><\/p>\n<p>Semilla usuario:<\/p>\n<pre class=\"javascript\" style=\"font-family: monospace;\"><span style=\"color: #3366cc;\">'use strict'<\/span><span style=\"color: #339933;\">;<\/span>\r\n\u00a0\r\nmodule.<span style=\"color: #660066;\">exports<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #009900;\">{<\/span>\r\n  up<span style=\"color: #339933;\">:<\/span> <span style=\"color: #009900;\">(<\/span>queryInterface<span style=\"color: #339933;\">,<\/span> Sequelize<span style=\"color: #009900;\">)<\/span> <span style=\"color: #339933;\">=&gt;<\/span> <span style=\"color: #009900;\">{<\/span>\r\n    <span style=\"color: #000066; font-weight: bold;\">return<\/span> queryInterface.<span style=\"color: #660066;\">bulkInsert<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #3366cc;\">'Usuarios'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">[<\/span>\r\n      <span style=\"color: #009900;\">{<\/span>\r\n        nombre<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'John'<\/span><span style=\"color: #339933;\">,<\/span>\r\n        apellidoP<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'Q'<\/span><span style=\"color: #339933;\">,<\/span>\r\n        apellidoM<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'Doe'<\/span><span style=\"color: #339933;\">,<\/span>\r\n        email<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'johndoe@gmail.com'<\/span><span style=\"color: #339933;\">,<\/span>\r\n        createdAt<span style=\"color: #339933;\">:<\/span> <span style=\"color: #000066; font-weight: bold;\">new<\/span> Date<span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n        updatedAt<span style=\"color: #339933;\">:<\/span> <span style=\"color: #000066; font-weight: bold;\">new<\/span> Date<span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n      <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #009900;\">]<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">{<\/span><span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n  <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span>\r\n\u00a0\r\n  down<span style=\"color: #339933;\">:<\/span> <span style=\"color: #009900;\">(<\/span>queryInterface<span style=\"color: #339933;\">,<\/span> Sequelize<span style=\"color: #009900;\">)<\/span> <span style=\"color: #339933;\">=&gt;<\/span> <span style=\"color: #009900;\">{<\/span>\r\n   <span style=\"color: #000066; font-weight: bold;\">return<\/span> queryInterface.<span style=\"color: #660066;\">bulkDelete<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #3366cc;\">'Usuarios'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #003366; font-weight: bold;\">null<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">{<\/span><span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n  <span style=\"color: #009900;\">}<\/span>\r\n<span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">;<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Semilla lenguajep:<\/p>\n<pre class=\"javascript\" style=\"font-family: monospace;\"><span style=\"color: #3366cc;\">'use strict'<\/span><span style=\"color: #339933;\">;<\/span>\r\n\u00a0\r\nmodule.<span style=\"color: #660066;\">exports<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #009900;\">{<\/span>\r\n  up<span style=\"color: #339933;\">:<\/span> <span style=\"color: #009900;\">(<\/span>queryInterface<span style=\"color: #339933;\">,<\/span> Sequelize<span style=\"color: #009900;\">)<\/span> <span style=\"color: #339933;\">=&gt;<\/span> <span style=\"color: #009900;\">{<\/span>\r\n   <span style=\"color: #000066; font-weight: bold;\">return<\/span> queryInterface.<span style=\"color: #660066;\">bulkInsert<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #3366cc;\">'LenguajePs'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">[<\/span>\r\n    <span style=\"color: #009900;\">{<\/span>\r\n      nombre<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'Java'<\/span><span style=\"color: #339933;\">,<\/span>\r\n      createdAt<span style=\"color: #339933;\">:<\/span> <span style=\"color: #000066; font-weight: bold;\">new<\/span> Date<span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n      updatedAt<span style=\"color: #339933;\">:<\/span> <span style=\"color: #000066; font-weight: bold;\">new<\/span> Date<span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #009900;\">{<\/span>\r\n      nombre<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'JavaScript'<\/span><span style=\"color: #339933;\">,<\/span>\r\n      createdAt<span style=\"color: #339933;\">:<\/span> <span style=\"color: #000066; font-weight: bold;\">new<\/span> Date<span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n      updatedAt<span style=\"color: #339933;\">:<\/span> <span style=\"color: #000066; font-weight: bold;\">new<\/span> Date<span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #009900;\">{<\/span>\r\n      nombre<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'PHP'<\/span><span style=\"color: #339933;\">,<\/span>\r\n      createdAt<span style=\"color: #339933;\">:<\/span> <span style=\"color: #000066; font-weight: bold;\">new<\/span> Date<span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n      updatedAt<span style=\"color: #339933;\">:<\/span> <span style=\"color: #000066; font-weight: bold;\">new<\/span> Date<span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #009900;\">{<\/span>\r\n      nombre<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'Go'<\/span><span style=\"color: #339933;\">,<\/span>\r\n      createdAt<span style=\"color: #339933;\">:<\/span> <span style=\"color: #000066; font-weight: bold;\">new<\/span> Date<span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n      updatedAt<span style=\"color: #339933;\">:<\/span> <span style=\"color: #000066; font-weight: bold;\">new<\/span> Date<span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #009900;\">{<\/span>\r\n      nombre<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'C++'<\/span><span style=\"color: #339933;\">,<\/span>\r\n      createdAt<span style=\"color: #339933;\">:<\/span> <span style=\"color: #000066; font-weight: bold;\">new<\/span> Date<span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n      updatedAt<span style=\"color: #339933;\">:<\/span> <span style=\"color: #000066; font-weight: bold;\">new<\/span> Date<span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span>\r\n  <span style=\"color: #009900;\">]<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">{<\/span><span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n  <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span>\r\n\u00a0\r\n  down<span style=\"color: #339933;\">:<\/span> <span style=\"color: #009900;\">(<\/span>queryInterface<span style=\"color: #339933;\">,<\/span> Sequelize<span style=\"color: #009900;\">)<\/span> <span style=\"color: #339933;\">=&gt;<\/span> <span style=\"color: #009900;\">{<\/span>\r\n   <span style=\"color: #000066; font-weight: bold;\">return<\/span> queryInterface.<span style=\"color: #660066;\">bulkDelete<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #3366cc;\">'LenguajePs'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #003366; font-weight: bold;\">null<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">{<\/span><span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n  <span style=\"color: #009900;\">}<\/span>\r\n<span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">;<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Semilla usuario_lenguajep:<\/p>\n<pre class=\"javascript\" style=\"font-family: monospace;\"><span style=\"color: #3366cc;\">'use strict'<\/span><span style=\"color: #339933;\">;<\/span>\r\n\u00a0\r\nmodule.<span style=\"color: #660066;\">exports<\/span> <span style=\"color: #339933;\">=<\/span> <span style=\"color: #009900;\">{<\/span>\r\n  up<span style=\"color: #339933;\">:<\/span> <span style=\"color: #009900;\">(<\/span>queryInterface<span style=\"color: #339933;\">,<\/span> Sequelize<span style=\"color: #009900;\">)<\/span> <span style=\"color: #339933;\">=&gt;<\/span> <span style=\"color: #009900;\">{<\/span>\r\n   <span style=\"color: #000066; font-weight: bold;\">return<\/span> queryInterface.<span style=\"color: #660066;\">bulkInsert<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #3366cc;\">'Usuario_LenguajePs'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">[<\/span>\r\n    <span style=\"color: #009900;\">{<\/span>\r\n      UsuarioId<span style=\"color: #339933;\">:<\/span> <span style=\"color: #cc0000;\">1<\/span><span style=\"color: #339933;\">,<\/span>\r\n      LenguajePId<span style=\"color: #339933;\">:<\/span> <span style=\"color: #cc0000;\">2<\/span><span style=\"color: #339933;\">,<\/span>\r\n      createdAt<span style=\"color: #339933;\">:<\/span> <span style=\"color: #000066; font-weight: bold;\">new<\/span> Date<span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n      updatedAt<span style=\"color: #339933;\">:<\/span> <span style=\"color: #000066; font-weight: bold;\">new<\/span> Date<span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #009900;\">{<\/span>\r\n      UsuarioId<span style=\"color: #339933;\">:<\/span> <span style=\"color: #cc0000;\">1<\/span><span style=\"color: #339933;\">,<\/span>\r\n      LenguajePId<span style=\"color: #339933;\">:<\/span> <span style=\"color: #cc0000;\">5<\/span><span style=\"color: #339933;\">,<\/span>\r\n      createdAt<span style=\"color: #339933;\">:<\/span> <span style=\"color: #000066; font-weight: bold;\">new<\/span> Date<span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n      updatedAt<span style=\"color: #339933;\">:<\/span> <span style=\"color: #000066; font-weight: bold;\">new<\/span> Date<span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span>\r\n  <span style=\"color: #009900;\">]<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">{<\/span><span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n  <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span>\r\n\u00a0\r\n  down<span style=\"color: #339933;\">:<\/span> <span style=\"color: #009900;\">(<\/span>queryInterface<span style=\"color: #339933;\">,<\/span> Sequelize<span style=\"color: #009900;\">)<\/span> <span style=\"color: #339933;\">=&gt;<\/span> <span style=\"color: #009900;\">{<\/span>\r\n   <span style=\"color: #000066; font-weight: bold;\">return<\/span> queryInterface.<span style=\"color: #660066;\">bulkDelete<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #3366cc;\">'Usuario_LenguajePs'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #003366; font-weight: bold;\">null<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900;\">{<\/span><span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n  <span style=\"color: #009900;\">}<\/span>\r\n<span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">;<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Ahora hay que cargar estos datos a la base de datos con el siguiente comando:<\/span><\/p>\n<pre class=\"bash\" style=\"font-family: monospace;\">sequelize db:seed:all<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Muy bi\u00e9n! Ya vimos c\u00f3mo inicializar un proyecto con sequelize, crear modelos, asignar relaciones, crear migraciones, correr y deshacer migraciones, crear semillas y cargarlas a la base de datos, solo nos falta hacer <a href=\"http:\/\/docs.sequelizejs.com\/manual\/tutorial\/querying.html\" target=\"_blank\" rel=\"noopener\">queries<\/a>.\u00a0Vamos a nuestro<em> index.js<\/em> en ra\u00edz y escribimos la siguiente funci\u00f3n:<\/span><\/p>\n<pre class=\"javascript\" style=\"font-family: monospace;\"><span style=\"color: #000066; font-weight: bold;\">const<\/span> db <span style=\"color: #339933;\">=<\/span> require<span style=\"color: #009900;\">(<\/span><span style=\"color: #3366cc;\">'.\/models'<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n\u00a0\r\n<span style=\"color: #000066; font-weight: bold;\">const<\/span> main <span style=\"color: #339933;\">=<\/span> async <span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span> <span style=\"color: #339933;\">=&gt;<\/span> <span style=\"color: #009900;\">{<\/span>\r\n    <span style=\"color: #000066; font-weight: bold;\">try<\/span> <span style=\"color: #009900;\">{<\/span>\r\n        <span style=\"color: #000066; font-weight: bold;\">const<\/span> usuarios <span style=\"color: #339933;\">=<\/span> await db.<span style=\"color: #660066;\">Usuario<\/span>.<span style=\"color: #660066;\">findAll<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">{<\/span>\r\n            include<span style=\"color: #339933;\">:<\/span> <span style=\"color: #009900;\">[<\/span><span style=\"color: #009900;\">{<\/span>\r\n                model<span style=\"color: #339933;\">:<\/span> db.<span style=\"color: #660066;\">LenguajeP<\/span><span style=\"color: #339933;\">,<\/span>\r\n                as<span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">'lenguajesProgramacion'<\/span><span style=\"color: #339933;\">,<\/span>\r\n                attributes<span style=\"color: #339933;\">:<\/span> <span style=\"color: #009900;\">{<\/span> exclude<span style=\"color: #339933;\">:<\/span> <span style=\"color: #009900;\">[<\/span><span style=\"color: #3366cc;\">'createdAt'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #3366cc;\">'updatedAt'<\/span><span style=\"color: #009900;\">]<\/span> <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span>\r\n                through<span style=\"color: #339933;\">:<\/span> <span style=\"color: #009900;\">{<\/span> attributes<span style=\"color: #339933;\">:<\/span> <span style=\"color: #009900;\">[<\/span><span style=\"color: #009900;\">]<\/span> <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span>\r\n            <span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">]<\/span><span style=\"color: #339933;\">,<\/span>\r\n        <span style=\"color: #009900;\">}<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n        console.<span style=\"color: #660066;\">log<\/span><span style=\"color: #009900;\">(<\/span>JSON.<span style=\"color: #660066;\">stringify<\/span><span style=\"color: #009900;\">(<\/span>usuarios<span style=\"color: #009900;\">)<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n        process.<span style=\"color: #660066;\">exit<\/span><span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n    <span style=\"color: #009900;\">}<\/span> <span style=\"color: #000066; font-weight: bold;\">catch<\/span> <span style=\"color: #009900;\">(<\/span>error<span style=\"color: #009900;\">)<\/span> <span style=\"color: #009900;\">{<\/span>\r\n        console.<span style=\"color: #660066;\">log<\/span><span style=\"color: #009900;\">(<\/span>error<span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n    <span style=\"color: #009900;\">}<\/span>\r\n<span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">;<\/span>\r\n\u00a0\r\nmain<span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Lo guardamos y ejecutamos el programa (ya sea por consola o con la herramienta de debug de visual studio code) y deber\u00edamos recibir un JSON con una lista de usuarios (en este ejemplo solo existe uno) con sus datos y lenguajes:<\/span><\/p>\n<pre class=\"javascript\" style=\"font-family: monospace;\"><span style=\"color: #009900;\">[<\/span>\r\n  <span style=\"color: #009900;\">{<\/span>\r\n    <span style=\"color: #3366cc;\">\"id\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #cc0000;\">1<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #3366cc;\">\"nombre\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">\"John\"<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #3366cc;\">\"apellidoP\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">\"Q\"<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #3366cc;\">\"apellidoM\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">\"Doe\"<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #3366cc;\">\"email\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">\"johndoe@gmail.com\"<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #3366cc;\">\"createdAt\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">\"2018-08-04T19:35:19.000Z\"<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #3366cc;\">\"updatedAt\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">\"2018-08-04T19:35:19.000Z\"<\/span><span style=\"color: #339933;\">,<\/span>\r\n    <span style=\"color: #3366cc;\">\"lenguajesProgramacion\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #009900;\">[<\/span>\r\n      <span style=\"color: #009900;\">{<\/span>\r\n        <span style=\"color: #3366cc;\">\"id\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #cc0000;\">2<\/span><span style=\"color: #339933;\">,<\/span>\r\n        <span style=\"color: #3366cc;\">\"nombre\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">\"JavaScript\"<\/span>\r\n      <span style=\"color: #009900;\">}<\/span><span style=\"color: #339933;\">,<\/span>\r\n      <span style=\"color: #009900;\">{<\/span>\r\n        <span style=\"color: #3366cc;\">\"id\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #cc0000;\">5<\/span><span style=\"color: #339933;\">,<\/span>\r\n        <span style=\"color: #3366cc;\">\"nombre\"<\/span><span style=\"color: #339933;\">:<\/span> <span style=\"color: #3366cc;\">\"C++\"<\/span>\r\n      <span style=\"color: #009900;\">}<\/span>\r\n    <span style=\"color: #009900;\">]<\/span>\r\n  <span style=\"color: #009900;\">}<\/span>\r\n<span style=\"color: #009900;\">]<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Aprendimos sequelize-cli y lo b\u00e1sico de Sequelize, ahora podemos crear un API que ejecute acciones CRUD para que nuestros clientes la consuman!<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>En este blog hablar\u00e9 un poco sobre los ORM\u2019s, sus beneficios (pros) y limitaciones (cons), que es Sequelize y c\u00f3mo usarlo. Object-Relational Mapping Es una t\u00e9cnica para convertir datos entre el sistema de tipos del lenguaje de programaci\u00f3n y la base de datos. Como su nombre lo indica, esto va dirigido solamente a las base [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":224,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35,7,34],"tags":[],"class_list":["post-213","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-desarrollo","category-desarrollo-de-software-a-la-medida","category-software"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>C\u00f3mo usar un ORM en Node.js &#8212; Desarrollo de software<\/title>\n<meta name=\"description\" content=\"Expertos en Desarrollo de Software, Aplicaci\u00f3nes M\u00f3viles, Node.js, React, React Native, Swift, Kotlin, Go, DJando, PHP, Python.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/\" \/>\n<meta property=\"og:locale\" content=\"es_MX\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C\u00f3mo usar un ORM en Node.js &#8212; Desarrollo de software\" \/>\n<meta property=\"og:description\" content=\"Expertos en Desarrollo de Software, Aplicaci\u00f3nes M\u00f3viles, Node.js, React, React Native, Swift, Kotlin, Go, DJando, PHP, Python.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/\" \/>\n<meta property=\"og:site_name\" content=\"Desarrollo de software\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/rosolutionsmx\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-08-06T19:23:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-10-09T19:18:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/rosolutions.com.mx\/blog\/wp-content\/uploads\/2018\/08\/node-js-736399_960_720.png\" \/>\n\t<meta property=\"og:image:width\" content=\"811\" \/>\n\t<meta property=\"og:image:height\" content=\"406\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Saul Alejandro Meneses\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ROSolutionsmx\" \/>\n<meta name=\"twitter:site\" content=\"@ROSolutionsmx\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"Saul Alejandro Meneses\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tiempo de lectura\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/\"},\"author\":{\"name\":\"Saul Alejandro Meneses\",\"@id\":\"https:\/\/rosolutions.com.mx\/blog\/#\/schema\/person\/7697657554cf053a122477c30abf3504\"},\"headline\":\"C\u00f3mo usar un ORM en Node.js\",\"datePublished\":\"2018-08-06T19:23:46+00:00\",\"dateModified\":\"2018-10-09T19:18:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/\"},\"wordCount\":1064,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/rosolutions.com.mx\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/rosolutions.com.mx\/blog\/wp-content\/uploads\/2018\/08\/node-js-736399_960_720.png\",\"articleSection\":[\"Desarrollo\",\"Programaci\u00f3n\",\"Software\"],\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/\",\"url\":\"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/\",\"name\":\"C\u00f3mo usar un ORM en Node.js &#8212; Desarrollo de software\",\"isPartOf\":{\"@id\":\"https:\/\/rosolutions.com.mx\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/rosolutions.com.mx\/blog\/wp-content\/uploads\/2018\/08\/node-js-736399_960_720.png\",\"datePublished\":\"2018-08-06T19:23:46+00:00\",\"dateModified\":\"2018-10-09T19:18:15+00:00\",\"description\":\"Expertos en Desarrollo de Software, Aplicaci\u00f3nes M\u00f3viles, Node.js, React, React Native, Swift, Kotlin, Go, DJando, PHP, Python.\",\"breadcrumb\":{\"@id\":\"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/#primaryimage\",\"url\":\"https:\/\/rosolutions.com.mx\/blog\/wp-content\/uploads\/2018\/08\/node-js-736399_960_720.png\",\"contentUrl\":\"https:\/\/rosolutions.com.mx\/blog\/wp-content\/uploads\/2018\/08\/node-js-736399_960_720.png\",\"width\":811,\"height\":406,\"caption\":\"logo node.js\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Inicio\",\"item\":\"https:\/\/rosolutions.com.mx\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C\u00f3mo usar un ORM en Node.js\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/rosolutions.com.mx\/blog\/#website\",\"url\":\"https:\/\/rosolutions.com.mx\/blog\/\",\"name\":\"Desarrollo de software\",\"description\":\"Blog de RO Solutions\",\"publisher\":{\"@id\":\"https:\/\/rosolutions.com.mx\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/rosolutions.com.mx\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/rosolutions.com.mx\/blog\/#organization\",\"name\":\"RO Solutions\",\"url\":\"https:\/\/rosolutions.com.mx\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/rosolutions.com.mx\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/rosolutions.com.mx\/blog\/wp-content\/uploads\/2018\/03\/icono-01-2.png\",\"contentUrl\":\"https:\/\/rosolutions.com.mx\/blog\/wp-content\/uploads\/2018\/03\/icono-01-2.png\",\"width\":350,\"height\":346,\"caption\":\"RO Solutions\"},\"image\":{\"@id\":\"https:\/\/rosolutions.com.mx\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/rosolutionsmx\/\",\"https:\/\/x.com\/ROSolutionsmx\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/rosolutions.com.mx\/blog\/#\/schema\/person\/7697657554cf053a122477c30abf3504\",\"name\":\"Saul Alejandro Meneses\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/7cd8031312d797524903f3d28ab113694c15f3eeca3188a84e097392844b71b6?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/7cd8031312d797524903f3d28ab113694c15f3eeca3188a84e097392844b71b6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/7cd8031312d797524903f3d28ab113694c15f3eeca3188a84e097392844b71b6?s=96&d=mm&r=g\",\"caption\":\"Saul Alejandro Meneses\"},\"sameAs\":[\"http:\/\/rosolutions.com.mx\"],\"url\":\"https:\/\/rosolutions.com.mx\/blog\/author\/saulmeneses\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C\u00f3mo usar un ORM en Node.js &#8212; Desarrollo de software","description":"Expertos en Desarrollo de Software, Aplicaci\u00f3nes M\u00f3viles, Node.js, React, React Native, Swift, Kotlin, Go, DJando, PHP, Python.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/","og_locale":"es_MX","og_type":"article","og_title":"C\u00f3mo usar un ORM en Node.js &#8212; Desarrollo de software","og_description":"Expertos en Desarrollo de Software, Aplicaci\u00f3nes M\u00f3viles, Node.js, React, React Native, Swift, Kotlin, Go, DJando, PHP, Python.","og_url":"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/","og_site_name":"Desarrollo de software","article_publisher":"https:\/\/www.facebook.com\/rosolutionsmx\/","article_published_time":"2018-08-06T19:23:46+00:00","article_modified_time":"2018-10-09T19:18:15+00:00","og_image":[{"width":811,"height":406,"url":"https:\/\/rosolutions.com.mx\/blog\/wp-content\/uploads\/2018\/08\/node-js-736399_960_720.png","type":"image\/png"}],"author":"Saul Alejandro Meneses","twitter_card":"summary_large_image","twitter_creator":"@ROSolutionsmx","twitter_site":"@ROSolutionsmx","twitter_misc":{"Escrito por":"Saul Alejandro Meneses","Tiempo de lectura":"8 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/#article","isPartOf":{"@id":"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/"},"author":{"name":"Saul Alejandro Meneses","@id":"https:\/\/rosolutions.com.mx\/blog\/#\/schema\/person\/7697657554cf053a122477c30abf3504"},"headline":"C\u00f3mo usar un ORM en Node.js","datePublished":"2018-08-06T19:23:46+00:00","dateModified":"2018-10-09T19:18:15+00:00","mainEntityOfPage":{"@id":"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/"},"wordCount":1064,"commentCount":2,"publisher":{"@id":"https:\/\/rosolutions.com.mx\/blog\/#organization"},"image":{"@id":"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/#primaryimage"},"thumbnailUrl":"https:\/\/rosolutions.com.mx\/blog\/wp-content\/uploads\/2018\/08\/node-js-736399_960_720.png","articleSection":["Desarrollo","Programaci\u00f3n","Software"],"inLanguage":"es","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/","url":"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/","name":"C\u00f3mo usar un ORM en Node.js &#8212; Desarrollo de software","isPartOf":{"@id":"https:\/\/rosolutions.com.mx\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/#primaryimage"},"image":{"@id":"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/#primaryimage"},"thumbnailUrl":"https:\/\/rosolutions.com.mx\/blog\/wp-content\/uploads\/2018\/08\/node-js-736399_960_720.png","datePublished":"2018-08-06T19:23:46+00:00","dateModified":"2018-10-09T19:18:15+00:00","description":"Expertos en Desarrollo de Software, Aplicaci\u00f3nes M\u00f3viles, Node.js, React, React Native, Swift, Kotlin, Go, DJando, PHP, Python.","breadcrumb":{"@id":"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/"]}]},{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/#primaryimage","url":"https:\/\/rosolutions.com.mx\/blog\/wp-content\/uploads\/2018\/08\/node-js-736399_960_720.png","contentUrl":"https:\/\/rosolutions.com.mx\/blog\/wp-content\/uploads\/2018\/08\/node-js-736399_960_720.png","width":811,"height":406,"caption":"logo node.js"},{"@type":"BreadcrumbList","@id":"https:\/\/rosolutions.com.mx\/blog\/como-usar-un-orm-en-node-js\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Inicio","item":"https:\/\/rosolutions.com.mx\/blog\/"},{"@type":"ListItem","position":2,"name":"C\u00f3mo usar un ORM en Node.js"}]},{"@type":"WebSite","@id":"https:\/\/rosolutions.com.mx\/blog\/#website","url":"https:\/\/rosolutions.com.mx\/blog\/","name":"Desarrollo de software","description":"Blog de RO Solutions","publisher":{"@id":"https:\/\/rosolutions.com.mx\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/rosolutions.com.mx\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"},{"@type":"Organization","@id":"https:\/\/rosolutions.com.mx\/blog\/#organization","name":"RO Solutions","url":"https:\/\/rosolutions.com.mx\/blog\/","logo":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/rosolutions.com.mx\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/rosolutions.com.mx\/blog\/wp-content\/uploads\/2018\/03\/icono-01-2.png","contentUrl":"https:\/\/rosolutions.com.mx\/blog\/wp-content\/uploads\/2018\/03\/icono-01-2.png","width":350,"height":346,"caption":"RO Solutions"},"image":{"@id":"https:\/\/rosolutions.com.mx\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/rosolutionsmx\/","https:\/\/x.com\/ROSolutionsmx"]},{"@type":"Person","@id":"https:\/\/rosolutions.com.mx\/blog\/#\/schema\/person\/7697657554cf053a122477c30abf3504","name":"Saul Alejandro Meneses","image":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/secure.gravatar.com\/avatar\/7cd8031312d797524903f3d28ab113694c15f3eeca3188a84e097392844b71b6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/7cd8031312d797524903f3d28ab113694c15f3eeca3188a84e097392844b71b6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7cd8031312d797524903f3d28ab113694c15f3eeca3188a84e097392844b71b6?s=96&d=mm&r=g","caption":"Saul Alejandro Meneses"},"sameAs":["http:\/\/rosolutions.com.mx"],"url":"https:\/\/rosolutions.com.mx\/blog\/author\/saulmeneses\/"}]}},"_links":{"self":[{"href":"https:\/\/rosolutions.com.mx\/blog\/wp-json\/wp\/v2\/posts\/213","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rosolutions.com.mx\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rosolutions.com.mx\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rosolutions.com.mx\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/rosolutions.com.mx\/blog\/wp-json\/wp\/v2\/comments?post=213"}],"version-history":[{"count":35,"href":"https:\/\/rosolutions.com.mx\/blog\/wp-json\/wp\/v2\/posts\/213\/revisions"}],"predecessor-version":[{"id":368,"href":"https:\/\/rosolutions.com.mx\/blog\/wp-json\/wp\/v2\/posts\/213\/revisions\/368"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rosolutions.com.mx\/blog\/wp-json\/wp\/v2\/media\/224"}],"wp:attachment":[{"href":"https:\/\/rosolutions.com.mx\/blog\/wp-json\/wp\/v2\/media?parent=213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rosolutions.com.mx\/blog\/wp-json\/wp\/v2\/categories?post=213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rosolutions.com.mx\/blog\/wp-json\/wp\/v2\/tags?post=213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}