What is the difference between save and insert in Mongo DB? both looks the same

db.users.save({username:"google",password:"google123"})

db.users.insert({username:"google",password:"google123"})



IN your given examples, the behavior is essentially the same.

save behaves differently if it is passed with an "_id" parameter.

If the document contains an _id field, then the save() method performs an upsert querying the collection on the _id field:

If a document does not exist with the specified _id value, the save() method performs an insert with the specified fields in the document.

If a document exists with the specified _id value, the save() method performs an update, replacing all field in the existing record with the fields from the document.
2 
What about save vs update with upsert:true ? –  Jeff Feb 14 at 12:40
3 
both have different syntax. Update takes multiple arguments ({condition},{update to doc}, upsert, multi) whereas save accepts only one argument(_id being the parameter for conditional argument).update can accept any condition but save has the limitation of condition only on the _id field. –  rahulroc Feb 17 at 4:33



save insert or update a document.

insert does only an insertion.

But in your case, it will do the same, as the document provided in save has no _id field.



source - http://stackoverflow.com/questions/16209681/what-is-the-difference-between-save-and-insert-in-mongo-db



'DB > MongoDB' 카테고리의 다른 글

mongodb - modify /etc/rc.d/init.d/mongod in fedora  (0) 2014.07.20
mongodb - mongodb.service for systemd  (0) 2014.07.20
mongo - v2.6 error  (0) 2014.04.25
mongodb gridfs - find files_id  (0) 2014.04.22
mongodb - $in, $all  (0) 2014.04.16
Posted by linuxism
,


WAI-ARIA (Web Accessibility Initiative - Accessible Rich Internet Applications) is a technical specification published by the World Wide Web Consortium that specifies how to increase the accessibility of web pages, in particular, dynamic content and user interface components developed with AjaxHTMLJavaScript and related technologies. As of March 2014, it was a Recommendation.[1]

Web developers increasingly use client-side scripts to create user interface controls that cannot be created with HTML alone. They also use client-side scripts to update sections of a page without requesting a completely new page from a web server. Such techniques on websites are called rich Internet applications. These user interface controls and content updates are often not accessible to users with disabilities, especially screen reader users and users who cannot use a mouse or other pointing device. WAI-ARIA allows web pages (or portions of pages) to declare themselves as applicationsrather than as static documents, by adding role, property, and state information to dynamic web applications. ARIA is intended for use by developers of web applicationsweb browsersassistive technologies, and accessibility evaluation tools.[2]

WAI-ARIA describes how to add semantics and other metadata to HTML content in order to make user interface controls and dynamic content more accessible. For example, with WAI-ARIA it is possible to identify a list of links as a navigation menu and to state whether it is expanded or collapsed. Although originally developed to address accessibility issues in HTML, the use of WAI-ARIA is not limited to HTML: in principle, it can also be used in other markup languages such as Scalable Vector Graphics (SVG). SVG 1.2 Tiny added support for WAI-ARIA in the 15 September 2008 working draft.[3]

The Web Accessibility Initiative has published an overview of WAI-ARIA[2] that introduces the subject and guides readers to the WAI-ARIA Suite documents:

Accessible Rich Internet Applications (WAI-ARIA) Version 1.0 (Draft)
[1] This is primarily aimed at developers of Web browsersassistive technologies, and other user agents, in addition to developers of other technical specifications, and developers of accessibility evaluation tools.
WAI-ARIA Primer
[4] This is a technical introduction to WAI-ARIA. It describes the problems WAI-ARIA tries to address, the underlying concepts, the technical approach and business reasons for adopting WAI-ARIA.
WAI-ARIA Best Practices
[5] This document describes best practices for delivering rich Internet applications with WAI-ARIA: it discusses subjects such as general steps for building accessible widgetskeyboard navigation, relationships, form properties, drag-and-drop support, alert and dialog boxesreusable component libraries, and testing.
Roadmap for Accessible Rich Internet Applications (WAI-ARIA Roadmap)
[6] Much of the content of this document has been moved into other documents.

The ARIA specifications editors have included Lisa Seeman, Rich Schwerdtfeger, James Craig, Michael Cooper and Lisa Pappas.

See also[edit]

References[edit]



source - http://en.wikipedia.org/wiki/WAI-ARIA






리치 인터넷 어플리케이션 접근성 (ARIAAccessible Rich Internet Applications)는 (특히 AJAX와 JavaScript를 사용하여 개발하는)웹 콘텐츠와 웹 어플리케이션을 제작할 때 장애인을 위한 접근성 향상 방법을 정의하고 있습니다. 예를 들어, ARIA는 접근가능한 네비게이션에 표시를 한다거나, JavaScript 위젯 사용이나, form 힌트 및 에러 메시지 그리고 실시간 콘텐츠 업데이트 등을 사용할 수 있도록 합니다.

ARIA는 어떤 마크업 요소에도 추가 가능한 접근성 속성의 집합이지만, 특히 HTML에 최적화되어 있습니다. role속성은 객체(article, alert, slider와 같은 것들)의 제너럴 타입을 정의할 수 있습니다. 추가로 ARIA 속성들은 form을 위한 설명이나 progressbar의 현재 값을 나타내어 주는 것과 같은 다른 유용한 프로퍼티들을 제공합니다.

ARIA는 대부분의 유명 브라우저들과 스크린리더에서 지원합니다. 그러나, 구현방식이 가지각색이며 오래된 기술들이 그를 잘 지원하지 않거나 전체를 지원하지 않습니다. "안전한" ARIA를 우아하게 낮추거나, 유저들에게 새로운 기술로 업그레이드 할 것을 요구하는 것 중 하나를 사용하십시요.


출처 - https://developer.mozilla.org/ko/docs/Web/Accessibility/ARIA





'Web > Common' 카테고리의 다른 글

web - woff, eot  (0) 2014.04.21
웹 페이지 속도 개선  (0) 2014.03.18
web - tomcat gzip config  (0) 2014.02.07
web - HATEOAS  (0) 2014.01.12
web - SPDY  (0) 2014.01.09
Posted by linuxism
,


I keep seeing role attributes in some people's work. I use it too, but I'm not sure about its effect.

f.e.:

<header id="header" role="banner">
    header stuff in here
</header>

or:

<section id="facebook" role="contentinfo">
    facebook stuff in here
</section>

or:

<section id="main" role="main">
     main content stuff in here
</section>

Is this role attribute necessary?

Is this attribute better for semantics?

Does it improve SEO?

A list of roles can be found here, but I see some people make up their own. Is that allowed or a correct use of the role attribute?

Any thoughts on this?



Most of the roles you see were defined as part of ARIA 1.0, and then later incorporated into HTML5. Some of the new HTML5 elements (dialog, main, etc.) are even based on the original ARIA roles.

http://www.w3.org/TR/wai-aria/

There are two primary reasons to use roles in addition to your native semantic element.

Reason #1. Overriding the role where no host language element is appropriate or, for various reasons, a less semantically appropriate element was used.

In this example, a link was used, even though the resulting functionality is more button-like than a navigation link.

<a href="#" role="button" aria-label="Delete item 1">Delete</a>

Screen readers will hear this as a button (as opposed to a link), and you can use a CSS attribute selector to avoid class-itis and div-itis.

*[role="button"] {
  /* style these a buttons w/o relying on a .button class */
}

Reason #2. Backing up a native element's role, to support browsers that implemented the ARIA role but haven't yet implemented the native element's role.

For example, the "main" role has been supported in browsers for many years, but it's a relatively recent addition to HTML5, so many browsers don't yet support the semantic for <main>.

<main role="main"></main>

This is technically redundant, but helps some users and doesn't harm any. In a few years, this technique will likely become unnecessary.

You also wrote:

I see some people make up their own. Is that allowed or a correct use of the role attribute?

That's not an invalid use of the attribute unless a real role is not included. Browsers will apply the first recognized role in the token list.

<span role="foo link note bar">...</a>

Out of the list, only link and note are valid roles, and so the link role will be applied because it comes first. If you use custom roles, make sure they don't conflict with any defined role in ARIA or the host language you're using (HTML, SVG, MathML, etc.)

answered Sep 6 '13 at 18:12



2 
This link may be helpful, too. Using ARIA in HTML. rawgithub.com/w3c/aria-in-html/master/index.html – James Craig Sep 6 '13 at 18:48 
1 
Why did you put universal selector in front of [role="button"]? –  Eugene Xa Oct 30 '13 at 17:47
   
@EugeneXa my guess is to pinpoint any element with the [role="button"] will save having to do a[role="button"], span[role="button"] –  Donald Dec 31 '13 at 15:42
1 
Fantastic answer. Very well written. –  Steve Jansen Jan 22 at 14:48
   
"In a few years, this technique will likely become unnecessary". Idk anything about accessibility, but with things like angular and web components creating custom tags, I can imagine this becoming more of a necessity. –  xdhmoore Jan 29 at 21:29



source - http://stackoverflow.com/questions/10403138/role-attribute-in-html






ARIA는 특정 요소가 담당하는 역할을 기준으로 role 속성에 지정할 수 있는 몇가지 속성값을 정의한다. 이를 기술적 용어로 온톨로지(ontology)를 부여한다고 표현한다.

랜드마크 역할 : 페이지 탐색을 목적으로 페이지 내의 특정 지점을 묘사한다.

    <nav role="navigation"> 과 같이 사용하여 스크린 리더가 이 영역을 쉽게 이동하도록 만들수 있다.

    banner - 특정 문서가 아닌 전체 사이트 영역을 지정, 예를 들어 사이트의 헤더나 로고

    application - 웹 애플리케이션에 사용되는 영역을 지정

    complementary - 페이지의 메인 섹션을 보완하는 영역을 지정

    contentinfo - 메인 콘텐츠의 정보를 지정. 예를 들어 페이지 하단의 저작권 정보 표시

    form - 웹 폼을 지정. 검색 엔진일 경우에는 대신 search를 사용

    main - 페이지의 메인 콘텐츠를 지정

    navigation - 현재 문서나 관련된 문서의 내비게이션 링크를 지정

    search - 검색을 수행하는 영역을 정의


- 문서의 구조 형성 역할 : 문서에서 구조를 형성하는 역할을 담당하는 요소에 부여한다.
   section, navigation, note, heading 속성값을 포함한다.


- 애플리케이션 구조 형성 역할 : 문서에서 애플리케이션 구조를 형성하는 요소에 부여한다.
   alert, alertdialog, progressbar, status 속성값을 포함한다.


- 사용자 인터페이스 역할
   treegrid, toolbar, menuitem 속성값을 포함한다.

사용자 입력 수신 역할
   checkbox, slider, option 속성값을 갖는다.


class 속성을 사용하는 것과 유사하다. 

예를 들어 type image인 요소를 버튼처럼 사용하려면 다음처럼 해당 input 요소의 속성에 button 값을 저장하면 된다.

HTML
<input type="image" src="btn-submit.png" role="button">

이 방법의 장점은 개발자 스스로 input 이미지의 역할이 버튼이라는 것을 바로 알수 있다는 것이다.
더 깊이 생각해보면 브라우저나 기타 다른 기기, 장애인과 더불어 모든 사용자가 더 쉽게 이 요소에 접근할 수 있다는 장점도 있다.



출처 - http://webdir.tistory.com/89





'Development > HTML' 카테고리의 다른 글

html - HTML DOM Events  (0) 2015.06.26
html - a tag에서 점선테두리 없애기  (0) 2015.06.15
html - <meta> http-equiv Attribute, X-UA-Compatible  (0) 2014.04.29
html - content type  (0) 2014.04.15
HTML DOM  (0) 2014.03.06
Posted by linuxism
,