在node.js中测试后清理数据库

编程入门 行业动态 更新时间:2024-10-26 22:27:24
本文介绍了在node.js中测试后清理数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

每次它后如何清理数据库?

How I can clean database after each it?

在Rails中,我使用 github/bmabey/database_cleaner ,但我确实做到了找不到与node.js类似的东西

In rails I use github/bmabey/database_cleaner, but I did't find something similar for node.js

node.js(v0.10.26),PostgreSQL(9.3.3),mocha,restify和knex.

node.js (v0.10.26), PostgreSQL (9.3.3), mocha, restify and knex.

推荐答案

我发现在测试之间清理数据库的简单方法是

The easy way I have found to clean the database between test is to

DROP SCHEMA public CASCADE; CREATE SCHEMA public AUTHORIZATION my_test_user;

一旦公共模式属于测试用户,他就可以在需要时删除并重新创建模式.请注意,删除数据库公共模式中的所有内容.

Once the public schema belongs to the test user, he is able to drop and re-create the schema when needed. Be aware that drop everything that lies in your database's public schema.

更多推荐

在node.js中测试后清理数据库

本文发布于:2023-10-19 00:04:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1505820.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库   测试   node   js

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!