-
Notifications
You must be signed in to change notification settings - Fork 12
Collection Update
RDMS μμ λ§νλ ν μ΄λΈμ΄ 컬λμ μ΄λΌ ν μ μκ³ ν μ΄λΈμ ꡬμ±νλ νλνλλ₯Ό ROW λΌ νλ€. νμ§λ§ baas.io λ μ΄κ²μ μν°ν°λΌκ³ λΆλ₯Έλ€.
μ μμ μμ±νλ mycollctions
컬λμ
μ μλμ°¨ μν°ν°λ₯Ό λ£λ λ°©λ²μ μ’ λ μμΈν μ΄ν΄λ³΄λλ‘ νμ.
λ¨Όμ μ½λλ₯Ό 보μ.
var myFirstApp = new Baas.IO({
orgName: 'YOUR_BAAS_IO_ID', // baas.io ID
appName: 'YOUR_BAAS_APP_ID', // baas.io Application ID
logging: false,
buildCurl: false
});
//μν°ν° μμ±
myFirstApp.createEntity(options, function (err, items) {
if (err){
//μλ¬
alert('μ€ν¨');
} else {
//μ±κ³΅
alert('μ±κ³΅');
}
});
μμ μ½λλ 컬λμ
μ μν°ν° λͺ©λ‘ κ°μ Έμ€κΈ° λ¬Έμλ₯Ό ν΅ν΄μ μ΄λ―Έ 보μμ κ²μ΄λ€. new Baas.IO
λ₯Ό ν΅ν΄ μ ν리μΌμ΄μ
μΈμ€ν΄μ€λ₯Ό μμ±νκ³ createEntity
λ©μλλ₯Ό ν΅ν΄ μ§μ ν type
μ¦ μ»¬λμ
μ μν°ν°λ₯Ό μμ±νλ λ°©λ²μ΄ μλ€. μ΄κ²μ μ ν리μΌμ΄μ
κ΄μ μμ μμ±νλ λ°©λ²μ΄λ€.
μ΄λ° λ°©μμ λ¨μΌ 컬λμ λ§ κ΄λ¦¬νλ©΄ λλ μ±μμλ μ μ©νμ§λ§ λ€μμ μ½λμ μ μ°κ΄κ΄κ³κ° νμν 볡μ‘ν μ±μμλ λΆνΈνλ€.
컬λμ μ΄ μ¬λ¬κ° μ¬μ©λλ μ±μμλ 컬λμ λ¨μμμ μν°ν°κ° μΆκ°λκ±°λ λ³κ²½, μμ λλ κ²½μ°κ° λ§μ΄ λ° μνλ€.
λ€μμ μκ°ν λ΄μ©μ 컬λμ μΈμ€ν΄μ€λ₯Ό μμ±νκ³ μ»¬λμ κ°μ²΄μ μν°ν°λ₯Ό κ΄λ¦¬νλ λ°©λ²μ μκ°νλ€.
- 컬λμ μΈμ€ν΄μ€ μμ±
컬λμ
μΈμ€ν΄μ€ μμ±μ createCollection
μ μ½λ°±ν¨μλ‘ μ λ¬λ λ λ²μ§Έ μΈμμ΄λ€. λ€μμ μ½λλ₯Ό 보μ.
μ μμ¬ν
μλμ μ½λλ₯Ό μ§μ μ€νν΄ λ³΄κΈ° μν΄μλ https://baas.io λ°μ΄ν°λΈλΌμ°μ μ
foocollections
μbarcollections
컬λμ μ΄ μ΄λ―Έ μ‘΄μ¬ν΄μΌ νλ€.
var fooCollection; // foo collection μΈμ€ν΄μ€
var barCollection; // bar collection μΈμ€ν΄μ€
var fooOptions = {
type: "foocollections"
};
var barOptions = {
type: "barcollections"
};
myFirstApp.createCollection(fooOptions, function(err, collectionObject) {
//foo 컬λμ
μΈμ€ν΄μ€λ₯Ό κΈλ‘λ² λ³μμ ν λΉ
fooCollection = collectionObject;
});
myFirstApp.createCollection(barOptions, function(err, collectionObject) {
//bar 컬λμ
μΈμ€ν΄μ€λ₯Ό κΈλ‘λ² λ³μμ ν λΉ
barCollection = collectionObject;
});
μμ μ½λλ foocollections
, barcollections
λκ°μ μΈμ€ν΄μ€λ₯Ό λ§λλ μ½λμ΄λ€. μΈμ€ν΄μ€κ° μμ±λμλ€λ©΄ μ΄μ foocollections
μ μν°ν°λ₯Ό μμ±ν΄ 보μ.
var options = {
name: 'ferrari',
year: 1851
};
fooCollection.addEntity(options, function(err, entity) {
if (err){
//μλ¬
alert('μ€ν¨');
} else {
//μ±κ³΅
alert('μ±κ³΅');
// μ½λ°±ν¨μ λ λ²μ§Έ μΈμλ‘ λμ΄μ¨ entity λ Baas.Entity μΈμ€ν΄μ€λ‘ μ λ¬λλ€.
}
});
μ μμ¬ν
λ§μ½ μμ±μ΄ λμ§ μκ³
"Uncaught TypeError: Cannot read property 'length' of undefined"
μλ¬λ401 unauthorize
μλ¬κ° λ°μνλ€λ©΄ ν΄λΉ 컬λ μ μ κΆνμ μ΄ν΄λ³Ό νμκ° μλ€. νμ¬ μ μ μκ² ν΄λΉ 컬λ μ μ μν°ν°λ₯Ό μΆκ°ν μ μλcreate
κΆνμ΄ λΆμ¬λμ΄ μλμ§ λ°μ΄ν°λΈλΌμ°μ role
μ½λ μ μμ νΈμ§ν μ μλ€.λ‘€κ³Ό νΌλ―Έμ κ³Ό κ΄λ ¨ν΄μλ λ³λμ νμ΄μ§λ₯Ό μ€λͺ ν μμ μ΄λ€.