我对couchdb很新,我想知道如何创建看起来像的ID.
Employee:DBX-**0001**-SP
数字部分0001必须是唯一的和顺序的.我怎样才能在couchdb中实现这样的功能?我搜遍了所有,我找不到任何简单的解决方案.
如果我可以在couchdb中而不是在客户端生成顺序部分以避免复制期间的冲突,那将是最好的.
我当前的解决方案是我获取一个我存储的文件,看起来像这个{"_ id":"EmployeeAutoIncrement",值:1}在检索时我增加值并将其发送回服务器,如果那些成功的话我返回新的递增值,并将其用作我的自动增量值,成为ID员工的一部分:DBX- AUTO_INCREMENT_VALUE_HERE -SP
这个问题是,如果两个人同时向EmployeeAutoIncrement发出请求并且他们都更新它会不会引起冲突?此外,如果一个人发出请求并且他们离线然后他们又回到网上那么那也不会发生冲突吗?
我正在尝试在我的selenium测试套件中执行JavaScript但它没有工作,我没有得到任何错误反馈.它优雅地接受我作为参数输入的任何内容到执行函数并通过测试.以下是我尝试过的组合:
class TestingStuff extends PHPUnit_Framework_TestCase {
protected function setUp() {
$this->webdriver = new WebDriver("localhost", 4444);
$this->webdriver->connect("firefox");
}
protected function tearDown() {
$this->webdriver->close();
}
public function testSomething() {
$this->webdriver->get('http://localhost/testdir/');
// Here is the execute function
$this->webdriver->execute('alert', 'Hello');
$this->webdriver->get('http://127.0.0.1/testdir/');
// Here is the execute function
$this->webdriver->execute('alert("Hello")', '');
$this->webdriver->get('http://127.0.0.1/testdir/');
// Here is the execute function
$this->webdriver->execute('javascript:alert("Hello")', '');
$this->webdriver->get('http://localhost/testdir/');
// Here is the execute function
$this->webdriver->execute('alert()', 'Hello');
}
}
Run Code Online (Sandbox Code Playgroud)
这是"WebDriver"类的功能:
/**
Inject a snippet of JavaScript into the page for execution in the context …Run Code Online (Sandbox Code Playgroud)