我刚开始使用React,所以这可能是一个非常简单的错误,但我们走了.我的HTML代码非常简单:
<!-- base.html -->
<html>
<head>
<title>Note Cards</title>
<script src="http://fb.me/react-0.11.2.js"></script>
<!-- <script src="http://fb.me/JSXTransformer-0.11.2.js"></script> -->
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static "css/style.css" %}">
<script src="{% static "build/react.js" %}"></script>
</head>
<body>
<h1 id="content">Note Cards</h1>
<div class="gotcha"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
请注意,我在这里使用django的加载静态文件.我的javascript有点复杂,所以我不会在这里发布所有内容,除非有人请求它,但错误的行是这样的:
React.renderComponent(
CardBox({url: "/cards/?format=json", pollInterval: 2000}),
document.getElementById("content")
);
Run Code Online (Sandbox Code Playgroud)
之后我得到'目标容器不是DOM元素错误'但似乎document.getElementById("content")几乎肯定是一个DOM元素.
我查看了这个 stackoverflow帖子,但它似乎对我的情况没有帮助.
任何人都知道我为什么会收到这个错误?
使用Postgres 9.4,我想在json列上创建一个索引,该索引将在搜索列中的特定键时使用.
例如,我有一个带有json列'animals'的'farm'表.
animals列具有一般格式的json对象:
'{"cow": 2, "chicken": 11, "horse": 3}'
Run Code Online (Sandbox Code Playgroud)
我已经尝试了许多索引(单独):
(1) create INDEX animal_index ON farm ((animal ->> 'cow'));
(2) create INDEX animal_index ON farm using gin ((animal ->> 'cow'));
(3) create INDEX animal_index ON farm using gist ((animal ->> 'cow'));
Run Code Online (Sandbox Code Playgroud)
我想运行如下查询:
SELECT * FROM farm WHERE (animal ->> 'cow') > 3;
Run Code Online (Sandbox Code Playgroud)
并让该查询使用索引.
当我运行此查询时:
SELECT * FROM farm WHERE (animal ->> 'cow') is null;
Run Code Online (Sandbox Code Playgroud)
然后(1)索引起作用,但我不能让任何索引适用于不等式.
这样的指数可能吗?
农场表只包含约5000个农场,但其中一些包含100个动物,查询对我的用例来说只需要太长时间.像这样的索引是我能想到的加速查询的唯一方法,但也许还有另一种选择.