小编Dav*_*ots的帖子

MongoDB的更新原子性是否适用于查询和修改?

MongoDB支持原子更新.即我可以肯定,当文档更新时,没有其他更新会覆盖我之前的更改.我的问题涉及查询和更新语句的组合,最好通过下面的示例说明.

db.foo.update(
{ state : 1, players: { $size: 2 } } , 
{ $push: { players : { new player document } } }, 
false , true );
Run Code Online (Sandbox Code Playgroud)

在上面的例子中,我只想将一个新玩家推入一个玩家集合,如果玩家数量等于2.鉴于上述查询和更新声明,两个同步更新是否可能将玩家推送到同一个文档,因为在阅读文件时其玩家的大小是2?即整个查询的原子性跨度和更新部分更新语句?

编辑更深入的事件序列:

考虑同时触发相同的更新两次(U1和U2).以下事件顺序是否可能?

  1. U1发现文档#1与更新语句的查询部分匹配.
  2. U2发现文档#1与更新语句的查询部分匹配.
  3. U1在文档#1中推送了一个新玩家.
  4. U2在文档#1中推出了一个新玩家.

最终结果是文档#1包含的玩家多于预期,因为U1和U2都认为文档#1只包含两个玩家.

mongodb

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

Angular 的自定义模块生命周期是怎样的?

是否有有关模块生命周期的信息。目前 Angular 内部组件的生命周期有很好的文档记录,我们有诸如 、 等钩子ngOnInit()方法ngDoCheck()

我们是否有类似的 Angular 模块生命周期钩子?我在哪里可以读到这方面的内容?

angular2-injection angular2-modules angular

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

mwlresizable 不起作用

我正在尝试调整图片大小,但是在鼠标抬起时,图片只是移动到新位置而不调整大小。

<img id=image1
       ngDraggable
       mwlResizable
       [enableGhostResize]="true"
       [resizeEdges]="{bottom: true, right: true, top: true, left: true}"
       (resizeEnd)="onResizeEnd($event)"
       src="{{user.picture}}">
Run Code Online (Sandbox Code Playgroud)

组件.ts:

import { ResizeEvent } from "angular-resizable-element";

export class Component{

  onResizeEnd(event: ResizeEvent): void {
    console.log('Element was resized', event);
  }
}
Run Code Online (Sandbox Code Playgroud)

应用模块:

...
import {ResizableModule} from "angular-resizable-element";


@NgModule({
  declarations: [
    AppComponent,
    MainComponent
  ],
  imports: [
    BrowserModule,

    HttpClientModule,
    AngularDraggableModule,
    ResizableModule
  ],
  providers: [GetJsonService],
  bootstrap: [AppComponent]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)

我按照书做了一切

javascript resize dynamic angular

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

如何在 TypeScript 中声明全局变量并在 Vue 中使用它

我有一个main.ts文件,我想在那里声明一个变量并在所有Vue文件中使用它。

我有一个包含以下内容的sfc.d.ts

declare module '*.vue' {
   import Vue from 'vue'
   export default Vue
}

declare var foo: any;
Run Code Online (Sandbox Code Playgroud)

foo = "1234"main.ts 中分配了一个值。如何foo在所有 Vue 文件中使用这个变量?或者有没有其他方法可以创建全局变量并使用它?

typescript vue.js

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

FormGroup错误TypeError:无法读取未定义的属性“ get”

我正在尝试从表单中获取值,并且出现此错误: ERROR TypeError:无法读取未定义的属性“ get”

 addMessage: FormGroup;
 get message(){ return this.addMessage.get('message').value}
Run Code Online (Sandbox Code Playgroud)

HTML:

 <form [formGroup]="addMessage" (ngSubmit)="sendMessage()">
      <input formControlName="message" class="input" type="text">
      <button type="submit" class="button is-primary">Send</button>
  </form>
Run Code Online (Sandbox Code Playgroud)

angular angular-forms

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

自动填充不工作iphone角度

我有一个Angular front应用程序,我的登录网页有问题.当我在iphone上使用自动填充功能在我的登录页面(ios 11.3)中自动填写登录名和密码输入时,登录名和密码是可见的,但是当我点击我的提交按钮时,应用程序在输入登录时没有检测到值并输入密码...如果我在登录名或密码输入中添加任何字符,我点击提交按钮,它正在工作......

为什么应用程序没有检测到自动填充值?这是一个有角度的问题?

ios angular

5
推荐指数
0
解决办法
198
查看次数

在Angular CLI中从ng-build中排除模块...不起作用

我有一个带有两个应用程序的Angular CLI项目。这两个应用程序是相同的,但是一个应用程序包含构建中的所有文件,另一个则需要排除模块。

Angular CLI版本:1.7.4 Angular版本:5.2.10

我将两个应用程序添加到angular-cli.json文件中,每个应用程序都有一个单独的ts-config文件。

  "apps": [
    {
      "name": "app",   <---- first app
      "root": "src",
      "outDir": "/wwwroot",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",       <----first TS config
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "styles.scss"
      ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    },
    {
      "name": "admin",   <---- second app
      "root": "src",
      "outDir": "/wwwroot",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": …
Run Code Online (Sandbox Code Playgroud)

typescript tsconfig angular-cli angular angular5

5
推荐指数
1
解决办法
5418
查看次数

Opensearch - 更改搜索引擎的名称

我一直在尝试将opensearch支持添加到我的网站.这就是我的opensearch.xml文件:

   <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
  <script/>
  <ShortName>Host</ShortName>
  <Description>Search my Website</Description>
  <InputEncoding>UTF-8</InputEncoding>
  <Image width="16" height="16" type="image/x-icon">Favicon url</Image>
  <Url type="application/x-suggestions+json" method="GET" template="http://suggestqueries.google.com/complete/search?output=firefox&amp;q={searchTerms}" />
  <Url type="text/html" method="GET" template="http://yoursite.com/?s={searchTerms}" />
  <SearchForm>http://yoursite.com/</SearchForm>
</OpenSearchDescription>
Run Code Online (Sandbox Code Playgroud)

但它在Chrome设置中以及按下标签提示时将网址名称注册为搜索引擎名称.我可以更改哪些内容以识别具有不同名称的搜索引擎?

google-chrome opensearch

5
推荐指数
1
解决办法
121
查看次数

如何将anime.js 导入我的Vue 项目?

我有一个关于将 导入anime.js到我的 vue 项目中的问题。我正在使用 vue cli。我如何包含animejs到我的项目中?我是这样试的:

import anime from 'animejs'
Vue.use(anime);
Run Code Online (Sandbox Code Playgroud)

但我在控制台中收到一条错误消息:

未捕获的类型错误:a.hasOwnProperty 不是函数。. .

你们能帮帮我吗?

vue.js anime.js

4
推荐指数
1
解决办法
4948
查看次数

Angular TypeError:无法在Promise subscription()中读取null的属性“ length”

我正在调用API端点并收到错误,但是使用console.log时无法查看错误,因为在下面出现错误。还有另一种方法来获取错误吗?

错误

TypeError: Cannot read property 'length' of null
    at http.js:109
    at Array.forEach (<anonymous>)
    at HttpHeaders.lazyInit (http.js:103)
    at HttpHeaders.init (http.js:251)
    at HttpHeaders.forEach (http.js:354)
    at Observable._subscribe (http.js:2153)
    at Observable._trySubscribe (Observable.js:172)
    at Observable.subscribe (Observable.js:160)
    at Object.subscribeToResult (subscribeToResult.js:23)
    at MergeMapSubscriber._innerSub (mergeMap.js:132)
Run Code Online (Sandbox Code Playgroud)

供应商

    import { HttpClient } from '@angular/common/http';
    import { Http, Headers , RequestOptions } from '@angular/http';
    import { Injectable } from '@angular/core';

    @Injectable()
    export class GamesProvider {

    // API url 
    apiUrl = 'http://xxxxx.com/api';

    headers : any;
    options: any;

    this.headers =  new Headers(); …
Run Code Online (Sandbox Code Playgroud)

angular

4
推荐指数
2
解决办法
4421
查看次数