{"id":12594,"date":"2021-12-15T14:44:31","date_gmt":"2021-12-15T22:44:31","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=12594"},"modified":"2025-06-13T22:40:21","modified_gmt":"2025-06-14T05:40:21","slug":"data-validation-with-the-eventing-service","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/pt\/data-validation-with-the-eventing-service\/","title":{"rendered":"Valida\u00e7\u00e3o de dados com o Eventing Service"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">A valida\u00e7\u00e3o de dados \u00e9 um t\u00f3pico interessante a ser abordado em uma tecnologia NoSQL, devido exclusivamente ao fato de que os princ\u00edpios fundamentais do sistema giram em torno de uma arquitetura \"sem esquema\". Durante muitos anos, o SQL e os esquemas controlaram os dados dos aplicativos, garantindo a conformidade das informa\u00e7\u00f5es dentro do banco de dados. Essas restri\u00e7\u00f5es impediram a moderniza\u00e7\u00e3o da maioria dos aplicativos, retardando o tempo de desenvolvimento.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Independentemente disso, voc\u00ea ainda precisa controlar e validar as informa\u00e7\u00f5es contidas nos seus aplicativos. Com isso em mente, como podemos fazer isso com o Couchbase?<\/span><\/p>\n<p><span style=\"font-weight: 400;\">A flexibilidade de uma arquitetura sem esquema torna mais dif\u00edcil impor a estrutura das informa\u00e7\u00f5es provenientes de v\u00e1rias fontes, como a intera\u00e7\u00e3o entre sensores e dispositivos de borda, em que o n\u00famero de pontos de comunica\u00e7\u00e3o \u00e9 grande. H\u00e1 maneiras de conseguir <\/span><b>valida\u00e7\u00e3o de dados no pr\u00f3prio banco de dados<\/b><span style=\"font-weight: 400;\">usando o servi\u00e7o Eventing do Couchbase. O servi\u00e7o, por si s\u00f3, \u00e9 extremamente avan\u00e7ado e flex\u00edvel, dando ao administrador controle sobre as especificidades da valida\u00e7\u00e3o nos documentos e as a\u00e7\u00f5es resultantes a serem tomadas.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">A postagem do blog apresentar\u00e1 um exemplo de uso do servi\u00e7o de eventos para validar as informa\u00e7\u00f5es que est\u00e3o em seu cluster. Como voc\u00ea ver\u00e1, h\u00e1 muitas maneiras diferentes de criar isso, mas vamos nos concentrar em apenas uma para come\u00e7ar.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Fundamentos de NoSQL<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">No centro de qualquer banco de dados est\u00e3o os dados - as informa\u00e7\u00f5es reais que desejamos armazenar. Antes de adotar o NoSQL, inser\u00edamos os dados em nosso sistema, mas eles tinham que aderir \u00e0 estrutura definida pelos desenvolvedores ou pelos DBAs. Os DBAs gastavam tempo <\/span><a href=\"https:\/\/en.wikipedia.org\/wiki\/Database_normalization\"><span style=\"font-weight: 400;\">normaliza\u00e7\u00e3o<\/span><\/a><span style=\"font-weight: 400;\"> as informa\u00e7\u00f5es at\u00e9 a 6\u00aa forma normal para reduzir a redund\u00e2ncia de dados<\/span><span style=\"font-weight: 400;\">. <\/span><span style=\"font-weight: 400;\">Toda essa estrutura era comumente conhecida como esquema e era excelente para validar a integridade das informa\u00e7\u00f5es, garantir a qualidade do sistema de registro e tornar-se uma fonte de verdade.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Apesar dos benef\u00edcios, a arquitetura baseada em esquema apresentou algumas desvantagens, principalmente quando os aplicativos come\u00e7aram a operar em um n\u00edvel mais alto e as empresas come\u00e7aram a inovar mais rapidamente. A abordagem estruturada para armazenar dados come\u00e7ou a desacelerar o desenvolvimento, e as altera\u00e7\u00f5es de esquema se tornaram um inc\u00f4modo.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Foi a\u00ed que a abordagem schema-lass come\u00e7ou a ter preced\u00eancia, permitindo que os usu\u00e1rios armazenassem qualquer informa\u00e7\u00e3o que desejassem e que a acelera\u00e7\u00e3o do desenvolvimento inovador florescesse.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-12595 size-full\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/12\/eventing.jpeg\" alt=\"\" width=\"512\" height=\"227\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/eventing.jpeg 512w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/eventing-300x133.jpeg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/eventing-20x9.jpeg 20w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/p>\n<h4><span style=\"font-weight: 400;\">SQL, mas NoSQL<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">Apesar da mudan\u00e7a para um banco de dados mais flex\u00edvel e \u00e1gil, alguns atributos do modelo antigo s\u00e3o desejados com a nova abordagem; a valida\u00e7\u00e3o de dados \u00e9 um desses t\u00f3picos. O Couchbase fez mudan\u00e7as consider\u00e1veis nas vers\u00f5es recentes para preencher a lacuna entre as tecnologias SQL e NoSQL.\u00a0<\/span><\/p>\n<p><b>Os escopos e as cole\u00e7\u00f5es eram <\/b><span style=\"font-weight: 400;\">lan\u00e7ado no Couchbase Server 7.0 e abriu as portas para uma maior organiza\u00e7\u00e3o l\u00f3gica e casos de uso de multiloca\u00e7\u00e3o. Isso nos permitiu mapear dados de esquema para sem esquema, mantendo as pr\u00e1ticas de desenvolvimento flex\u00edveis no n\u00facleo.\u00a0<\/span><\/p>\n<p><b>Fornecimento de garantias ACID <\/b><span style=\"font-weight: 400;\">de um sistema distribu\u00eddo foi outro grande passo, garantindo a sem\u00e2ntica do tipo \"tudo ou nada\" em dados n\u00e3o relacionados para cargas de trabalho transacionais na vers\u00e3o 6.5.1.<\/span><\/p>\n<p><b>Valida\u00e7\u00e3o de dados <\/b><span style=\"font-weight: 400;\">\u00e9 outro t\u00f3pico que aparece junto com esses. Como avalio as informa\u00e7\u00f5es em meu banco de dados quando n\u00e3o h\u00e1 um esquema que as imponha? Assim como os recursos anteriores que complementaram a abordagem de esquema, a capacidade de escolher se voc\u00ea tem isso ou n\u00e3o \u00e9 ben\u00e9fica. No entanto, n\u00e3o \u00e9 necess\u00e1rio incorporar isso aos fundamentos do pr\u00f3prio aplicativo.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Com a prolifera\u00e7\u00e3o da rede 5G e dos dispositivos m\u00f3veis\/de borda, \u00e9 prov\u00e1vel que a exig\u00eancia de governan\u00e7a e gerenciamento de dados ainda exista. A utiliza\u00e7\u00e3o de ferramentas no arsenal do Couchbase pode fornecer um m\u00e9todo f\u00e1cil e totalmente controlado de aplicar essa valida\u00e7\u00e3o sem afetar o desempenho dos n\u00f3s do aplicativo ou do banco de dados.\u00a0<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Computa\u00e7\u00e3o de borda com v\u00e1rias fontes de aplicativos<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">Antes de nos aprofundarmos nas formas divertidas de valida\u00e7\u00e3o no servidor, vamos discutir a outra op\u00e7\u00e3o dispon\u00edvel. A valida\u00e7\u00e3o no n\u00edvel do aplicativo provavelmente ser\u00e1 o primeiro pensamento que vir\u00e1 \u00e0 mente. Se quisermos garantir que as informa\u00e7\u00f5es sejam adequadas para armazenamento, por que n\u00e3o as verificamos antes de inserir os documentos no banco de dados? A aplica\u00e7\u00e3o da l\u00f3gica do aplicativo nos dados antes da ingest\u00e3o pelo sistema garantiria que nenhum documento chegaria perto do banco de dados, a menos que o sistema j\u00e1 o tivesse validado.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-12596 size-full\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/12\/eventing2.jpeg\" alt=\"\" width=\"512\" height=\"150\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/eventing2.jpeg 512w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/eventing2-300x88.jpeg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/eventing2-20x6.jpeg 20w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Teoricamente, essa parece ser uma boa ideia.... para um \u00fanico aplicativo que se comunica com um \u00fanico conjunto de dados. Entretanto, quando come\u00e7amos a analisar o espa\u00e7o dos aplicativos m\u00f3veis, em que poder\u00edamos estar falando com v\u00e1rios dispositivos de borda, todos falando com v\u00e1rios conjuntos de dados, em um \u00fanico banco de dados, a capacidade de manuten\u00e7\u00e3o ser\u00e1 prejudicada. Todas as equipes que escrevem no banco de dados precisariam manter e compartilhar a l\u00f3gica de valida\u00e7\u00e3o de forma consistente, e voc\u00ea come\u00e7a a perder as garantias que existiam no cen\u00e1rio de um \u00fanico aplicativo.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-12597 size-full\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/12\/eventing-3.jpeg\" alt=\"\" width=\"512\" height=\"420\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/eventing-3.jpeg 512w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/eventing-3-300x246.jpeg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/eventing-3-20x16.jpeg 20w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/p>\n<h4><span style=\"font-weight: 400;\">Servi\u00e7o de eventos<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">Considerando os problemas de valida\u00e7\u00e3o do aplicativo, precisamos de uma maneira de obter o mesmo resultado, mas em um ponto diferente; \u00e9 a\u00ed que entra o servi\u00e7o de eventos. Para aqueles que n\u00e3o o conhecem, o servi\u00e7o de eventos permite que voc\u00ea atue em muta\u00e7\u00f5es de dados no banco de dados de forma program\u00e1tica. Essas a\u00e7\u00f5es s\u00e3o definidas em manipuladores de eventos JavaScript e s\u00e3o acionadas em qualquer atualiza\u00e7\u00e3o ou exclus\u00e3o de dados.<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><em><span style=\"font-weight: 400;\">fun\u00e7\u00e3o<\/span> <span style=\"font-weight: 400;\">Sobre a atualiza\u00e7\u00e3o<\/span><span style=\"font-weight: 400;\">(doc, meta) {<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 log(<\/span><span style=\"font-weight: 400;\">'docId'<\/span><span style=\"font-weight: 400;\">, meta.id);<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">}<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">fun\u00e7\u00e3o<\/span> <span style=\"font-weight: 400;\">OnDelete<\/span><span style=\"font-weight: 400;\">(meta, op\u00e7\u00f5es) {<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">}<\/span><\/em><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">Como o servi\u00e7o de eventos pode executar essa l\u00f3gica ap\u00f3s a entrada dos dados no banco de dados, nada nos impede de incorporar a l\u00f3gica do aplicativo a essas fun\u00e7\u00f5es. Passaremos a responsabilidade ao servi\u00e7o de eventos para verificar as informa\u00e7\u00f5es sempre que elas forem inseridas ou modificadas.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Isso faz duas coisas:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Elimina a duplica\u00e7\u00e3o da l\u00f3gica de valida\u00e7\u00e3o em v\u00e1rios aplicativos<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Centralizar a configura\u00e7\u00e3o e a capacidade de manuten\u00e7\u00e3o do que \u00e9 considerado dados \"v\u00e1lidos<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Agora podemos usar o servi\u00e7o de eventos para verificar os campos e valores do documento em um bucket, independentemente da origem dos dados. Mas ainda h\u00e1 uma considera\u00e7\u00e3o a ser feita: o que faremos com os documentos se decidirmos que eles s\u00e3o <\/span><i><span style=\"font-weight: 400;\">inv\u00e1lido<\/span><\/i><span style=\"font-weight: 400;\">? No n\u00edvel do aplicativo, um documento inv\u00e1lido n\u00e3o passaria nas verifica\u00e7\u00f5es e lan\u00e7aria um erro ou uma exce\u00e7\u00e3o, que poderia ser tratada da maneira que fosse necess\u00e1ria.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Como as informa\u00e7\u00f5es j\u00e1 est\u00e3o no balde, precisamos sinalizar a validade do documento sem prejudicar a integridade dos dados. Cabe a voc\u00ea decidir como lidar com essa parte, mas, no meu exemplo, podemos manter um registro dos documentos inv\u00e1lidos em uma cole\u00e7\u00e3o separada e podemos remover o registro quando ele tiver sido limpo para um estado v\u00e1lido.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-12598 size-full\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/12\/eventing-4.jpeg\" alt=\"\" width=\"512\" height=\"447\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/eventing-4.jpeg 512w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/eventing-4-300x262.jpeg 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/eventing-4-20x17.jpeg 20w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/p>\n<h4><span style=\"font-weight: 400;\">Implementa\u00e7\u00e3o<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">Primeiro, precisamos criar uma fun\u00e7\u00e3o de eventos no conjunto de dados de destino. Para este exemplo, escolhi a fun\u00e7\u00e3o <\/span><i><span style=\"font-weight: 400;\">Usu\u00e1rios <\/span><\/i><span style=\"font-weight: 400;\">cole\u00e7\u00e3o. Tamb\u00e9m precisaremos especificar um local para armazenar os metadados de eventos (consulte a se\u00e7\u00e3o <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/eventing\/eventing-Terminologies.html\"><span style=\"font-weight: 400;\">documenta\u00e7\u00e3o de eventos aqui<\/span><\/a><span style=\"font-weight: 400;\">).<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Por fim, precisarei definir um alias para o local dos dados inv\u00e1lidos, ao qual posso fazer refer\u00eancia; para isso, temos o <\/span><i><span style=\"font-weight: 400;\">Usu\u00e1rios_Inv\u00e1lidos <\/span><\/i><span style=\"font-weight: 400;\">cole\u00e7\u00e3o.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-12599 size-full\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2021\/12\/eventing5.png\" alt=\"\" width=\"451\" height=\"348\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/eventing5.png 451w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/eventing5-300x231.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/eventing5-20x15.png 20w\" sizes=\"auto, (max-width: 451px) 100vw, 451px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Uma vez que a estrutura tenha sido criada, precisamos criar algo que represente um <\/span><i><span style=\"font-weight: 400;\">v\u00e1lido<\/span><\/i><span style=\"font-weight: 400;\"> documento. Dessa forma, podemos verificar todos os novos documentos com base nesse documento para garantir que as informa\u00e7\u00f5es estejam corretas. Neste caso, criarei um documento que lista todos os campos obrigat\u00f3rios e os tipos que eles devem conter. Se quiser, voc\u00ea pode correlacionar isso com o esquema que discutimos anteriormente, portanto, chamarei esse documento de <\/span><i><span style=\"font-weight: 400;\">Esquema_de_usu\u00e1rios<\/span><\/i><span style=\"font-weight: 400;\">.<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><em><span style=\"font-weight: 400;\">{<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \"fields\": [<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\">{<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 <\/span> <span style=\"font-weight: 400;\">\"name\": <\/span><span style=\"font-weight: 400;\">\"Nome\"<\/span><span style=\"font-weight: 400;\">,<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 <\/span> <span style=\"font-weight: 400;\">\"tipo\": <\/span><span style=\"font-weight: 400;\">\"string\"<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\">},<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\">{<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 <\/span> <span style=\"font-weight: 400;\">\"name\": <\/span><span style=\"font-weight: 400;\">\"Idade\"<\/span><span style=\"font-weight: 400;\">,<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 <\/span> <span style=\"font-weight: 400;\">\"tipo\": <\/span><span style=\"font-weight: 400;\">\"n\u00famero\"<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\">},<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\">{<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 <\/span> <span style=\"font-weight: 400;\">\"name\": <\/span><span style=\"font-weight: 400;\">\"Assinante\"<\/span><span style=\"font-weight: 400;\">,<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 <\/span> <span style=\"font-weight: 400;\">\"tipo\": <\/span><span style=\"font-weight: 400;\">\"booleano\"<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\">}<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 ]<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">}<\/span><\/em><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">A pr\u00f3xima coisa a ser criada \u00e9 a l\u00f3gica de valida\u00e7\u00e3o. O Eventing executar\u00e1 a l\u00f3gica sempre que houver uma muta\u00e7\u00e3o de documento na cole\u00e7\u00e3o de origem, <\/span><i><span style=\"font-weight: 400;\">Usu\u00e1rios<\/span><\/i><span style=\"font-weight: 400;\">. Ele verificar\u00e1 se o documento tem um documento de esquema relacionado associado. Em caso afirmativo, verifica todos os tipos de campos e valores e os compara com o documento que est\u00e1 sendo referenciado. Se algum dos campos n\u00e3o existir ou algum dos tipos n\u00e3o corresponder ao esperado, criaremos um registro no arquivo <\/span><i><span style=\"font-weight: 400;\">Usu\u00e1rios inv\u00e1lidos <\/span><\/i><span style=\"font-weight: 400;\">cole\u00e7\u00e3o.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">H\u00e1 uma condi\u00e7\u00e3o na parte inferior do script que tenta excluir o registro se a l\u00f3gica retornar um resultado v\u00e1lido. Ele \u00e9 removido dos registros inv\u00e1lidos quando o documento \u00e9 limpo ou corrigido para um estado v\u00e1lido.<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><em><span style=\"font-weight: 400;\">fun\u00e7\u00e3o<\/span> <span style=\"font-weight: 400;\">Sobre a atualiza\u00e7\u00e3o<\/span><span style=\"font-weight: 400;\">(doc, meta) {<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\">log(<\/span><span style=\"font-weight: 400;\">'docId'<\/span><span style=\"font-weight: 400;\">, meta.id);<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\">var<\/span><span style=\"font-weight: 400;\"> schema, valid, reason<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\">\/Recolha o documento do esquema<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\">schema = inv[doc.type + <\/span><span style=\"font-weight: 400;\">'_schema'<\/span><span style=\"font-weight: 400;\">]<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\">motivo = <\/span><span style=\"font-weight: 400;\">&#8221;<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\">v\u00e1lido = <\/span><span style=\"font-weight: 400;\">verdadeiro<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\">\/\/Iterar pelos campos<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\">para<\/span><span style=\"font-weight: 400;\">(<\/span><span style=\"font-weight: 400;\">const<\/span><span style=\"font-weight: 400;\"> campo <\/span><span style=\"font-weight: 400;\">de<\/span><span style=\"font-weight: 400;\"> schema.fields) {<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 <\/span> <span style=\"font-weight: 400;\">\u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">\/Verificar se o campo existe<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 <\/span> <span style=\"font-weight: 400;\">\u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">se<\/span><span style=\"font-weight: 400;\"> (field.name <\/span><span style=\"font-weight: 400;\">em<\/span><span style=\"font-weight: 400;\"> doc) {<\/span><\/em><em><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">\/Verificar se o tipo de campo est\u00e1 correto<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span> <span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">se<\/span><span style=\"font-weight: 400;\"> (<\/span><span style=\"font-weight: 400;\">tipo de<\/span><span style=\"font-weight: 400;\"> doc[field.name] == field.type) {<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 v\u00e1lido = <\/span><span style=\"font-weight: 400;\">verdadeiro<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span> <span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 }<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">mais<\/span><span style=\"font-weight: 400;\"> {<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 motivo = <\/span><span style=\"font-weight: 400;\">'Incorrect Type for Field: '<\/span><span style=\"font-weight: 400;\"> + field.name + <\/span><span style=\"font-weight: 400;\">'. Esperado: '<\/span><span style=\"font-weight: 400;\"> + field.type + <\/span><span style=\"font-weight: 400;\">'. Real: '<\/span><span style=\"font-weight: 400;\"> + <\/span><span style=\"font-weight: 400;\">tipo de<\/span><span style=\"font-weight: 400;\"> doc[field.name]<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 v\u00e1lido = <\/span><span style=\"font-weight: 400;\">falso<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">quebra<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 <\/span> <span style=\"font-weight: 400;\">\u00a0 \u00a0 }<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 <\/span> <span style=\"font-weight: 400;\">\u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">mais<\/span><span style=\"font-weight: 400;\"> {<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 motivo = <\/span><span style=\"font-weight: 400;\">'Campo: '<\/span><span style=\"font-weight: 400;\"> + field.name + <\/span><span style=\"font-weight: 400;\">' n\u00e3o existe'<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span> <span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 v\u00e1lido = <\/span><span style=\"font-weight: 400;\">falso<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">quebra<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 <\/span> <span style=\"font-weight: 400;\">\u00a0 \u00a0 }<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\">}<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\">se<\/span><span style=\"font-weight: 400;\"> (valid == <\/span><span style=\"font-weight: 400;\">verdadeiro<\/span><span style=\"font-weight: 400;\">){<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 <\/span> <span style=\"font-weight: 400;\">\u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">excluir<\/span><span style=\"font-weight: 400;\"> inv[meta.id]<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\">}<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\">mais<\/span><span style=\"font-weight: 400;\"> {<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 <\/span> <span style=\"font-weight: 400;\">\u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">var<\/span><span style=\"font-weight: 400;\"> docContent = {<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span> <span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">\"id\"<\/span><span style=\"font-weight: 400;\">: meta.id,<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"font-weight: 400;\">\"raz\u00e3o\"<\/span><span style=\"font-weight: 400;\">: motivo<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 <\/span> <span style=\"font-weight: 400;\">\u00a0 \u00a0 }<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">\u00a0 \u00a0 <\/span> <span style=\"font-weight: 400;\">\u00a0 \u00a0 inv[meta.id] = docContent<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span> <span style=\"font-weight: 400;\">}<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><span style=\"font-weight: 400;\">}<\/span><\/em><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">Tudo o que h\u00e1 a fazer agora \u00e9 test\u00e1-lo, inserir um <\/span><i><span style=\"font-weight: 400;\">Usu\u00e1rio <\/span><\/i><span style=\"font-weight: 400;\">com campos\/tipos inv\u00e1lidos e verifique se um registro \u00e9 criado no <\/span><i><span style=\"font-weight: 400;\">Usu\u00e1rios inv\u00e1lidos<\/span><\/i><span style=\"font-weight: 400;\"> collection\". Tente corrigir os documentos inv\u00e1lidos e verifique se o registro foi removido. Em geral, isso permite que voc\u00ea obtenha valida\u00e7\u00e3o ass\u00edncrona de dados ap\u00f3s o ponto de salvamento, em tr\u00eas etapas simples.<\/span><\/p>\n<h4><span style=\"font-weight: 400;\">Indo al\u00e9m...<\/span><\/h4>\n<p><span style=\"font-weight: 400;\">Como voc\u00ea deve ter percebido, esse \u00e9 um exemplo muito simples, e n\u00e3o tenho d\u00favidas de que poderia ter escrito o JavaScript de forma mais eficiente. No entanto, ainda consegui validar todas as informa\u00e7\u00f5es em um bucket em rela\u00e7\u00e3o ao que poder\u00edamos chamar de esquema, mantendo a integridade das informa\u00e7\u00f5es e garantindo que n\u00e3o houvesse perda de dados no processo.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Essa abordagem era a que eu queria seguir, mas poderia ser modificada e ampliada de v\u00e1rias maneiras diferentes...<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Valida\u00e7\u00e3o dos valores reais dos campos (por exemplo, a idade deve estar no intervalo de 1 a 100, etc.)<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Remo\u00e7\u00e3o total dos documentos da cole\u00e7\u00e3o<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Mover o documento inteiro para fora da cole\u00e7\u00e3o<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Envio de notifica\u00e7\u00f5es via cURL para um servi\u00e7o externo (resposta de e-mail, talvez?)<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Escrever l\u00f3gica extra para corrigir de forma aut\u00f4noma os dados inv\u00e1lidos com enriquecimento<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Esta postagem do blog demonstrou algumas coisas:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Valida\u00e7\u00e3o ass\u00edncrona de dados ap\u00f3s o ponto de salvamento<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">O poder do servi\u00e7o de eventos como um todo<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">Voltando aos pontos originais, a ponte entre as tecnologias SQL e NoSQL est\u00e1 se tornando cada vez mais comum, n\u00e3o como mudan\u00e7as arquitet\u00f4nicas, mas como ferramentas para alcan\u00e7ar o que antes era uma implementa\u00e7\u00e3o fundamental.<\/span><\/p>","protected":false},"excerpt":{"rendered":"<p>Data Validation is an interesting topic to cover for a NoSQL technology, purely down to the fact that the core principles of the system revolve around a &#8220;schema-less&#8221; architecture. For many years, SQL and schemas have controlled application data, ensuring [&hellip;]<\/p>","protected":false},"author":74466,"featured_media":12603,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1816,2273,1812],"tags":[1572,1725],"ppma_author":[9167],"class_list":["post-12594","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-couchbase-server","category-eventing","category-n1ql-query","tag-database","tag-nosql-database"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.4 (Yoast SEO v26.4) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Data Validation with the Eventing Service - The Couchbase Blog<\/title>\n<meta name=\"description\" content=\"The blog post shows you how to use the Couchbase Eventing Service to perform data validation within the NoSQL database.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/pt\/data-validation-with-the-eventing-service\/\" \/>\n<meta property=\"og:locale\" content=\"pt_BR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Data Validation with the Eventing Service\" \/>\n<meta property=\"og:description\" content=\"The blog post shows you how to use the Couchbase Eventing Service to perform data validation within the NoSQL database.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/pt\/data-validation-with-the-eventing-service\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2021-12-15T22:44:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T05:40:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/hannah-wei-aso6SYJZGps-unsplash-scaled.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1707\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Daniel Bull, Associate Solutions Engineer\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Daniel Bull, Associate Solutions Engineer\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/\"},\"author\":{\"name\":\"Daniel Bull, Associate Solutions Engineer\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/7f9d5e0c7963a172db12fb5e5e2583e1\"},\"headline\":\"Data Validation with the Eventing Service\",\"datePublished\":\"2021-12-15T22:44:31+00:00\",\"dateModified\":\"2025-06-14T05:40:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/\"},\"wordCount\":1714,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/hannah-wei-aso6SYJZGps-unsplash-scaled.jpg\",\"keywords\":[\"database\",\"NoSQL Database\"],\"articleSection\":[\"Couchbase Server\",\"Eventing\",\"SQL++ \/ N1QL Query\"],\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/\",\"name\":\"Data Validation with the Eventing Service - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/hannah-wei-aso6SYJZGps-unsplash-scaled.jpg\",\"datePublished\":\"2021-12-15T22:44:31+00:00\",\"dateModified\":\"2025-06-14T05:40:21+00:00\",\"description\":\"The blog post shows you how to use the Couchbase Eventing Service to perform data validation within the NoSQL database.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/#breadcrumb\"},\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/hannah-wei-aso6SYJZGps-unsplash-scaled.jpg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/hannah-wei-aso6SYJZGps-unsplash-scaled.jpg\",\"width\":2560,\"height\":1707,\"caption\":\"Couchbase ASP.NET Core tutorial\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Data Validation with the Eventing Service\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"pt-BR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/7f9d5e0c7963a172db12fb5e5e2583e1\",\"name\":\"Daniel Bull, Associate Solutions Engineer\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/1a793e281f03204d89cd07cc2163a58e\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/07\/daniel-bull-couchbase-engineering.jpeg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/07\/daniel-bull-couchbase-engineering.jpeg\",\"caption\":\"Daniel Bull, Associate Solutions Engineer\"},\"description\":\"Daniel Bull is an Associate Solutions Engineer at Couchbase\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/daniel-bull-00a102b5\/\"],\"url\":\"https:\/\/www.couchbase.com\/blog\/pt\/author\/daniel-bull\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Data Validation with the Eventing Service - The Couchbase Blog","description":"A postagem do blog mostra como usar o Couchbase Eventing Service para realizar a valida\u00e7\u00e3o de dados no banco de dados NoSQL.","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:\/\/www.couchbase.com\/blog\/pt\/data-validation-with-the-eventing-service\/","og_locale":"pt_BR","og_type":"article","og_title":"Data Validation with the Eventing Service","og_description":"The blog post shows you how to use the Couchbase Eventing Service to perform data validation within the NoSQL database.","og_url":"https:\/\/www.couchbase.com\/blog\/pt\/data-validation-with-the-eventing-service\/","og_site_name":"The Couchbase Blog","article_published_time":"2021-12-15T22:44:31+00:00","article_modified_time":"2025-06-14T05:40:21+00:00","og_image":[{"width":2560,"height":1707,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/hannah-wei-aso6SYJZGps-unsplash-scaled.jpg","type":"image\/jpeg"}],"author":"Daniel Bull, Associate Solutions Engineer","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Daniel Bull, Associate Solutions Engineer","Est. reading time":"9 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/"},"author":{"name":"Daniel Bull, Associate Solutions Engineer","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/7f9d5e0c7963a172db12fb5e5e2583e1"},"headline":"Data Validation with the Eventing Service","datePublished":"2021-12-15T22:44:31+00:00","dateModified":"2025-06-14T05:40:21+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/"},"wordCount":1714,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/hannah-wei-aso6SYJZGps-unsplash-scaled.jpg","keywords":["database","NoSQL Database"],"articleSection":["Couchbase Server","Eventing","SQL++ \/ N1QL Query"],"inLanguage":"pt-BR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/","url":"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/","name":"Data Validation with the Eventing Service - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/hannah-wei-aso6SYJZGps-unsplash-scaled.jpg","datePublished":"2021-12-15T22:44:31+00:00","dateModified":"2025-06-14T05:40:21+00:00","description":"A postagem do blog mostra como usar o Couchbase Eventing Service para realizar a valida\u00e7\u00e3o de dados no banco de dados NoSQL.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/#breadcrumb"},"inLanguage":"pt-BR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/"]}]},{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/hannah-wei-aso6SYJZGps-unsplash-scaled.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/12\/hannah-wei-aso6SYJZGps-unsplash-scaled.jpg","width":2560,"height":1707,"caption":"Couchbase ASP.NET Core tutorial"},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/data-validation-with-the-eventing-service\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Data Validation with the Eventing Service"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"Blog do Couchbase","description":"Couchbase, o banco de dados NoSQL","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"pt-BR"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"Blog do Couchbase","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/7f9d5e0c7963a172db12fb5e5e2583e1","name":"Daniel Bull, engenheiro de solu\u00e7\u00f5es associado","image":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/1a793e281f03204d89cd07cc2163a58e","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/07\/daniel-bull-couchbase-engineering.jpeg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/07\/daniel-bull-couchbase-engineering.jpeg","caption":"Daniel Bull, Associate Solutions Engineer"},"description":"Daniel Bull \u00e9 engenheiro de solu\u00e7\u00f5es associado da Couchbase","sameAs":["https:\/\/www.linkedin.com\/in\/daniel-bull-00a102b5\/"],"url":"https:\/\/www.couchbase.com\/blog\/pt\/author\/daniel-bull\/"}]}},"authors":[{"term_id":9167,"user_id":74466,"is_guest":0,"slug":"daniel-bull","display_name":"Daniel Bull, Associate Solutions Engineer","avatar_url":{"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/07\/daniel-bull-couchbase-engineering.jpeg","url2x":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2021\/07\/daniel-bull-couchbase-engineering.jpeg"},"author_category":"","last_name":"Bull","first_name":"Daniel","job_title":"","user_url":"","description":"Daniel Bull \u00e9 engenheiro de solu\u00e7\u00f5es associado da Couchbase"}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts\/12594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/users\/74466"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/comments?post=12594"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/posts\/12594\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/media\/12603"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/media?parent=12594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/categories?post=12594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/tags?post=12594"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/pt\/wp-json\/wp\/v2\/ppma_author?post=12594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}