सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
Realm फ्लटर के लिए आधिकारिक मोबाइल डेटाबेस SDK है, जो SQLite और की-वैल्यू स्टोर के लिए एक तेज, लचीला और स्केलेबल विकल्प प्रदान करता है। यह रियल-टाइम सिंक्रनाइजेशन, रिएक्टिव डेटा बाइंडिंग और डार्ट/फ्लटर ऐप्स के साथ बिना किसी दिक्कत के एकीकरण प्रदान करता है। Realm Android, iOS, macOS, Windows और Linux जैसे कई प्लेटफॉर्म का समर्थन करता है, जिससे डेवलपर्स डिवाइस के बीच एक समान डेटा के साथ ऑफलाइन-फर्स्ट ऐप्स बना सकते हैं। इसका उपयोग करने में आसान API डेटा मॉडलिंग और क्वेरी को सरल बनाता है, जबकि बिल्ट-इन एन्क्रिप्शन डेटा सुरक्षा सुनिश्चित करता है। Realm उच्च प्रदर्शन और कम लेटेंसी के लिए डिज़ाइन किया गया है, जो डायनामिक, डेटा-ड्राइवन ऐप्स के लिए आदर्श है।
उपयोग
ऑफलाइन-प्रथम मोबाइल एप्स
रियल-टाइम डेटा सिंक्रनाइज़ेशन
क्रॉस-प्लेटफॉर्म डेटा स्थायित्व
उच्च प्रदर्शन डेटा प्राप्त करना
सुरक्षित स्थानीय डेटा संग्रहण
मुख्य विशेषताएँ
रियल-टाइम डेटा अपडेट
प्रतिक्रियाशील प्रोग्रामिंग समर्थन
प्लेटफॉर्म के अनुकूलता
एम्बेडेड एन्क्रिप्शन
स्पष्ट ऑब्जेक्ट-ओरिएंटेड API
इनके लिए उपयुक्त
मोबाइल ऐप विकासकर्ता
डेटा-गहन एप्लिकेशन
ऑफलाइन कार्यक्षमता की आवश्यकता वाले ऐप्स
क्रॉस-प्लेटफॉर्म समाधान बनाने वाली टीमें
त्वरित स्थानीय डेटा पहुँच की आवश्यकता वाले प्रोजेक्ट
विचार योग्य बातें
वस्तु-अभिमुख डेटा मॉडलिंग की समझ की आवश्यकता होती है
SQL की तुलना में सीमित प्रश्न कठिनाई
माइग्रेशन रणनीतियों को सावधानीपूर्वक योजना बनाने की आवश्यकता होती है
नए उपयोगकर्ताओं के लिए सीखने का वक्र
सिंक (वैकल्पिक) के लिए रील्म के क्लाउड सेवाओं पर निर्भरता
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
[!WARNING]
We announced the deprecation of Atlas Device Sync + Realm SDKs in September 2024. For more information please see:
For a version of realm-dart without sync features, install version 20 or see the community branch.
Realm is a mobile database that runs directly inside phones, tablets or wearables.
This repository holds the source code for the Realm SDK for Flutter™ and Dart™.
Features
Mobile-first: Realm is the first database built from the ground up to run directly inside phones, tablets, and wearables.
Simple: Realm’s object-oriented data model is simple to learn, doesn’t need an ORM, and the API lets you write less code to get apps up & running in minutes.
Modern: Realm supports latest Dart and Flutter versions and is built with sound null-safety.
Fast: Realm is faster than even raw SQLite on common operations while maintaining an extremely rich feature set.
import'package:realm/realm.dart'; // import realm packagepart'app.realm.dart'; // declare a part file.@RealmModel() // define a data model class named `_Car`.class_Car{
lateString make;
lateString model;
int? kilometers = 500;
}
Generate RealmObject class Car from data model class _Car.
dart run realm generate
Open a Realm and add some objects.
var config = Configuration.local([Car.schema]);
var realm = Realm(config);
var car = Car("Tesla", "Model Y", kilometers: 5);
realm.write(() {
realm.add(car);
});
Query objects in Realm.
var cars = realm.all<Car>();
Car myCar = cars[0];
print("My car is ${myCar.make} model ${myCar.model}");
cars = realm.all<Car>().query("make == 'Tesla'");
Generate RealmObject class Item from data model class _Item.
On Flutter use dart run realm to run realm package commands
dart run realm generate
A new file catalog.realm.dart will be created next to the catalog.dart.
*The generated file should be committed to source control
Use the RealmObject class Item with Realm.
// Create a Configuration objectvar config = Configuration.local([Item.schema]);
// Opean a Realmvar realm = Realm(config);
var myItem = Item(0, 'Pen', price: 4);
// Open a write transaction
realm.write(() {
realm.add(myItem);
var item = realm.add(Item(1, 'Pencil')..price = 20);
});
// Objects `myItem` and `item` are now managed and persisted in the realm// Read object properties from realmprint(myItem.name);
print(myItem.price);
// Update object properties
realm.write(() {
myItem.price = 20;
myItem.name = "Special Pencil";
});
// Get objects from the realm// Get all objects of typevar items = realm.all<Item>();
// Get object by indexvar item = items[1];
// Get object by primary keyvar itemByKey = realm.find<Item>(0);
// Filter and sort objectvar objects = realm.query<Item>("name == 'Special Pencil'");
var name = 'Pen';
objects = realm.query<Item>(r'name == $0', [name]);
// Close the realm
realm.close();
Full contents of catalog.dart
import'package:realm/realm.dart';
part'catalog.realm.dart';
@RealmModel()
class_Item{
@PrimaryKey()
lateint id;
lateString name;
int price = 42;
}
// Create a Configuration objectvar config = Configuration.local([Item.schema]);
// Open a Realmvar realm = Realm(config);
var myItem = Item(0, 'Pen', price: 4);
// Open a write transaction
realm.write(() {
realm.add(myItem);
var item = realm.add(Item(1, 'Pencil')..price = 20);
});
// Objects `myItem` and `item` are now managed and persisted in the realm// Read object properties from realmprint(myItem.name);
print(myItem.price);
// Update object properties
realm.write(() {
myItem.price = 20;
myItem.name = "Special Pencil";
});
// Get objects from the realm// Get all objects of typevar items = realm.all<Item>();
// Get object by indexvar item = items[1];
// Get object by primary keyvar itemByKey = realm.find<Item>(0);
// Filter and sort objectvar objects = realm.query<Item>("name == 'Special Pencil'");
var name = 'Pen';
objects = realm.query<Item>(r'name == $0', [name]);
// Close the realm
realm.close();
Initialize the App Services App client and authenticate a user.
String appId = "<Atlas App ID>";
final appConfig = AppConfiguration(appId);
final app = App(appConfig);
final user = await app.logIn(Credentials.anonymous());
Open a synced realm.
final config = Configuration.flexibleSync(user, [Task.schema]);
final realm = Realm(config);
Add a sync subscription and write data.
Only data matching the query in the subscription will be synced to the server and only data matching the subscription will be downloaded to the local device realm file.
realm.subscriptions.update((mutableSubscriptions) {
mutableSubscriptions.add(realm.query<Task>(r'status == $0 AND progressMinutes == $1', ["completed", 100]));
});
await realm.subscriptions.waitForSynchronization();
realm.write(() {
realm.add(Task(ObjectId(), "Send an email", "completed", 4));
realm.add(Task(ObjectId(), "Create a meeting", "completed", 100));
realm.add(Task(ObjectId(), "Call the manager", "init", 2));
});
realm.close();
See CONTRIBUTING.md for instructions about building the source.
Code of Conduct
This project adheres to the MongoDB Code of Conduct.
By participating, you are expected to uphold this code. Please report
unacceptable behavior to [community-conduct@mongodb.com](mailto:community-conduct@mongodb.com).
License
Realm Flutter and Dart SDKs and Realm Core are published under the Apache License 2.0.
The "Dart" name and logo and the "Flutter" name and logo are trademarks owned by Google.