Docs 菜单
Docs 主页
/ /
Atlas Device SDKs
/ /

CRUD - 创建 - Node.js SDK

在此页面上

  • 创建新对象

要将对象添加到 Realm,请像实例化任何其他对象一样实例化该对象,然后将其传递给写事务内的Realm.create() 。如果 Realm 的模式包含对象类型,并且对象符合该模式,则 Realm 会存储该对象,该对象现在由 Realm托管

// Declare the variable that will hold the dog instance.
let dog;
// Open a transaction.
realm.write(() => {
// Assign a newly-created instance to the variable.
dog = realm.create("Dog", { name: "Max", age: 5 });
});
// use newly created dog object

后退

CRUD

来年

读取

在此页面上