小编big*_*ato的帖子

ElasticSearch:如何在字符串字段为空或空的情况下编写查询?

我想查看有的文件media_url == '' || media_url == null.我有一个问题:

{
    "engagements": [
        "blah"
    ],
    "query": {
        "from": 0,
        "size": 2,
        "sort": [
            {
                "bookmarked": {
                    "order": "desc"
                }
            },
            {
                "created_at": {
                    "order": "desc"
                }
            }
        ],
        "facets": {},
        "query": {
            "filtered": {
                "query": {
                    "match_all": {}
                },
                "filter": {
                    "bool": {
                        "must": [
                            {
                                "term": {
                                    "car_id": "78778"
                                }
                            },
                            {
                                "range": {
                                    "created_at": {
                                        "gte": "2015-04-12T04:00:00.000Z",
                                        "lte": "2015-05-13T03:59:59.999Z"
                                    }
                                }
                            },
                            {
                                "term": {
                                    "media_url": ""
                                }
                            } …
Run Code Online (Sandbox Code Playgroud)

elasticsearch

8
推荐指数
1
解决办法
2万
查看次数

Firebase:如何按键查询?

我有一个我想查询的位置表.关键是"050PNS74ZW8XZ".

在此输入图像描述

如你所见,它存在.

但是,当我打印出任何属性时,它不起作用

function testing(req, resp) {
  const location = database.ref('locations').equalTo('050PNS74ZW8XZ');
  console.log('location:', location.account_capabilities); // <--- prints undefined
  resp.json("asfdsf");
}
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么???

firebase firebase-realtime-database

8
推荐指数
1
解决办法
1万
查看次数

React Native:React Native使用的默认字体是什么?

我正在尝试使用与React Native中默认使用的字体相同的字体制作图形,但我不知道字体是什么。

有人知道吗

react-native

8
推荐指数
2
解决办法
8212
查看次数

如何在node_modules中模拟库?

我正在尝试为使用 node-forge 的代码编写测试。由于某种原因,当我调用时测试挂起forge.md.sha256.create();

  import forge from "node-forge";

  const privateKey = "foo";
  const storagePin = "bar";

  const md = forge.md.sha256.create();
  md.update(privateKey + storagePin);

  const metadataKey = md.digest().toHex();
Run Code Online (Sandbox Code Playgroud)

作为解决方法,我尝试模拟该方法的实现,以便它只返回一个硬编码的字符串:

import forge from "node-forge";
jest.mock("node-forge");

forge.mockImplementation(() => {
  return {
    md: {
      sha256: {
        create: () => {
          return {
            update: () => {},
            digest: () => {
              toHex: () => "foobar";
            }
          };
        }
      }
    }
  };
});


// tests
Run Code Online (Sandbox Code Playgroud)

然而,我的测试一直失败:

TypeError: _nodeForge2.default.mockImplementation is not a function

  at Object.<anonymous> (src/redux/epics/authentication-epic.test.js:20:27) …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs jestjs

8
推荐指数
1
解决办法
1万
查看次数

Ruby:STDIN.gets()和gets.chomp()之间有什么区别?

Ruby STDIN.gets()gets.chomp()Ruby 之间的区别是什么?他们不是都从用户那里检索原始输入吗?

问题:如果我想将他们的输入转换为整数,我该怎么做

myNumb = Integer(STDIN.gets())
Run Code Online (Sandbox Code Playgroud)

myNumb = Integer(gets.chomp()) 
Run Code Online (Sandbox Code Playgroud)

ruby

7
推荐指数
3
解决办法
1万
查看次数

React Native:borderBottomWidth无法正常工作

import React from 'react';
import { View, StyleSheet, Text } from 'react-native';
import Fonts from '../Fonts';
import Screen from '../Screen';

const styles = StyleSheet.create({
  container: {
    alignItems: "center",
    backgroundColor: "rgba(12, 22, 32, 0.88)",
    flex: 1,
    justifyContent: "center",
    borderBottomWidth: 2,
    borderBottomColor: "#47315a",
  },
  content: {
    backgroundColor: "white",
    alignItems: "center",
    height: Screen.height() - 450.0,
    width: Screen.width() - 50.0,
    padding: 10,
    borderBottomWidth: 2,
    borderBottomColor: "#47315a",
  },
  header: {
    alignItems: "center",
    paddingBottom: 10,
    justifyContent: "center",
    color: "#0B1219",
    fontFamily: Fonts.Knockout31JuniorMiddleWeight,
    fontSize: 26.0,
    borderBottomWidth: 5,
    borderBottomColor: …
Run Code Online (Sandbox Code Playgroud)

react-native

7
推荐指数
1
解决办法
5504
查看次数

React Native:生产中的关键窗口没有设置维度

我收到了这个错误

RCTFatalException: Unhandled JS Exception: No dimension set for key windowmh_execute_header Unhandled JS Exception: No dimension set for key window, stack: value@75:505

在生产中.我相信这是RN的一个问题:https://github.com/facebook/react-native/issues/13758

该线程中的所有解决方案看起来都与开发环境相似.有没有办法解决这个问题(在上传新的课程后)?

  "dependencies": {
    "@yfuks/react-native-action-sheet": "latest",
    "bugsnag-react-native": "^2.2.3",
    "iap-receipt-validator": "^1.0.6",
    "js-uuid": "^0.0.6",
    "lodash": "^4.17.4",
    "moment": "^2.17.1",
    "phoenix": "^1.2.1",
    "react": "16.0.0-alpha.6",
    "react-native": "0.44.0",
    "react-native-animatable": "^1.1.0",
    "react-native-aws3": "^0.0.8",
    "react-native-code-push": "^2.0.3-beta",
    "react-native-collapsible": "^0.8.0",
    "react-native-elevated-view": "^0.0.3",
    "react-native-firestack": "^2.3.9",
    "react-native-flags": "^1.0.0",
    "react-native-geocoder": "^0.4.8",
    "react-native-image-picker": "^0.26.1",
    "react-native-image-resizer": "^0.1.0",
    "react-native-in-app-utils": "^5.2.3",
    "react-native-incall-manager": "^2.1.0",
    "react-native-keep-awake": "^2.0.4",
    "react-native-loading-spinner-overlay": "latest",
    "react-native-localization": "^0.1.30",
    "react-native-modalbox": "^1.3.9",
    "react-native-permissions": …
Run Code Online (Sandbox Code Playgroud)

react-native

7
推荐指数
1
解决办法
1505
查看次数

CSS:如何隐藏文件输入但保留文件名?

我想隐藏文件输入“选择文件”按钮,但我想保留文件名。我怎样才能做到这一点?

在此输入图像描述

<input
  name="upload"
  id="upload-input"
  placeholder="Select a file"
  ref="fileInput"
  type="file"
  required>
Run Code Online (Sandbox Code Playgroud)

html css

7
推荐指数
1
解决办法
4950
查看次数

Storybook + React:SVG 图标导致元素类型无效:需要字符串(对于内置组件)或类/函数

我有一个 React 组件:

import React from 'react';



import { ReactComponent as IncreaseIcon } from '../icons/increase.svg';



const StatCard = ({
  className,
  value,
  percentChange,
  description,
  tooltipDescription
}) => (
  <Container className={className}>
    ...
      <h1>
        <IncreaseIcon />
        123%
      </h1>
    ...
  </Container>
);

export default StatCard;
Run Code Online (Sandbox Code Playgroud)

当我加载我的 React 应用程序时,该组件本身可以工作,但是当我尝试将其加载到故事书中时,它失败了:

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have …

reactjs styled-components storybook

7
推荐指数
0
解决办法
5343
查看次数

Rails 4:has_one关联是否有first_or_initialize?

我有一个Purchasehas_one :shipping_address.

在我的一种方法中,我有这个:

@shipping_address ||= purchase.build_shipping_address(
  first_name: shipping_address_first_name,
  ...
)
Run Code Online (Sandbox Code Playgroud)

但是,我想抓住附加到购买的现有shipping_address(如果它存在)而不是总是创建一个新的替换(我相信删除旧的替换并在数据库中创建一个新的替换).

purchase.first_or_build_shipping_address(...)在Rails中有办法吗?

ruby-on-rails

6
推荐指数
1
解决办法
2094
查看次数