SQL을 Firebase로 다시 작성하기위한 치트 모음

8415 단어 Firebasenosql

RDS 데이터 구조





Firebase 데이터 구조





//rootRef points every single piece of data in the database.
const rootRef = firebase.database().ref();

no1.sql
select * from Users where UID = 1;
conts oneRef = rootRef.child('users').child('1');

no1.sql
select * from Users where Email = '[email protected]';
cont twoRef = rootRef.child('users').orderByChild('email').equalTo('[email protected]');

no2.sql
select * from Users LIMIT 10;
const threeRef = rootRef.child('users').limitTofirst(10);

no3.sql
select * from Users where Name LIKE 'D%';
const fourRef = rootRef.child('users').orderByChild('name').startAt('D').endAt('D\ut8ff');

no4.sql
select * from Users where age < 50;
const fiveRef = rootRef.child('users').orderByChild('age').endAt(49);

no5.sql
select * from Users where age > 50;
const sixRef = rootRef.child('users').orderByChild('age').startAt(51);

no6.sql
select * from Users where age >= 20 $$ age <= 100;
const sevenRef = rootRef.child('users').orderByChild('age').startAt(20).endAt(100);

no7.sql
select * from Users where age = 28 && location = 'Tokyo'
This is NG!!
const eightRef = rootRef.child('users').orderByChild('age').equalTo(28)
                                       .orderByChild('location').equalTo('Berlin');
You should change Data structure of Object..When you use two conditions
const eightRef = rootRef.child('users').orderByChild('age_locatoin').equalTo('28_Tokyo');

참고는 이쪽

좋은 웹페이지 즐겨찾기