神刀安全网

13,949 Commits and 6,148 Closed Issues Later: Thank You for Helping Realm Reach 1.0

It was July of 2014 when we announced Realm as “the first mobile-first database.” Today — 13,949 commits and 6,148 closed issues later — we’re proud to release Realm 1.0, a major milestone not only for Realm as a company and a product, but also for the iOS and Android developer communities that have embraced Realm.

When we launched, we only offered an Objective-C version of Realm for iOS and Mac developers. First-class support for Swift and an Android version were added later, and just recently we launched initial support for React Native and Xamarin. As a result, Realm is now available to every major mobile platform and programming language. This release is the culmination of more than two years of hard work building and shipping products, and we could not have gotten here without the tremendous support of the community. Thank you! :clap:

Even before reaching 1.0, Realm has been broadly adopted by the mobile dev community. You’ve given us over 12,000 stars on GitHub (and counting). Realm is currently used by more than 100,000 active developers and in tens of thousands of apps, including apps with massive usage from companies like Starbucks, Twitter, Anheuser-Busch, NBCUniversal, Alibaba, eBay, and thousands more. They are using Realm because Realm makes their apps better — the developers behind those apps can build better user experiences, more easily and more quickly. With today’s 1.0 release, they can be further assured that Realm products for iOS and Android have reached a key stage of maturity and stability.

To see what has changed, you can look at our changelogs for Java , Objective-C, and Swift .

What is Realm?

Realm is not an ORM, and is not built on top of SQLite. Instead we’ve built a full database for mobile app developers, one that uses native objects that are dynamically mapped to a full, custom database engine (not just a key-value store). This allows us to provide a simple API while even enhancing performance. With Realm, you can model complex data, link objects in a graph, and compose advanced queries.

// Define you model class by extending RealmObject public class Dog extends RealmObject {     private String name;     private int age;      // ... Generated getters and setters ... }  public class Person extends RealmObject {     @PrimaryKey     private long id;     private String name;     private RealmList<Dog> dogs; // Declare one-to-many relationships      public Person(long id, String name) {         this.id = id;         this.name = name;     }      // ... Generated getters and setters ... }  // Use them like regular java objects Dog dog = new Dog(); dog.setName("Rex"); dog.setAge(1);  // Create a RealmConfiguration that saves the Realm file in the app's "files" directory. RealmConfiguration realmConfig = new RealmConfiguration.Builder(context).build(); Realm.setDefaultConfiguration(realmConfig);  // Get a Realm instance for this thread Realm realm = Realm.getDefaultInstance();  // Query Realm for all dogs younger than 2 years old final RealmResults<Dog> puppies = realm.where(Dog.class).lessThan("age", 2).findAll(); puppies.size(); // => 0 because no dogs have been added to the Realm yet  // Persist your data in a transaction realm.beginTransaction(); final Dog managedDog = realm.copyToRealm(dog); // Persist unmanaged objects Person person = realm.createObject(Person); // Create managed objects directly person.getDogs().add(managedDog); realm.commitTransaction();  // Listeners will be notified when data changes puppies.addChangeListener(new RealmChangeListener<RealmResults<Dog>>() {     @Override     public void onChange(RealmResults<Dog> results) {         // Query results are updated in real time         puppies.size(); // => 1     } });  // Asynchronously update objects on a background thread realm.executeTransactionAsync(new Realm.Transaction() {     @Override     public void execute(Realm bgRealm) {         Dog dog = bgRealm.where(Dog.class).equals("age", 1).findFirst();         dog.setAge(3);     } }, new Realm.Transaction.OnSuccess() {     @Override     public void onSuccess() {       // Original queries and Realm objects are automatically updated.       puppies.size(); // => 0 because there are no more puppies younger than 2 years old       managedDog.getAge();   // => 3 the dogs age is updated     } });

// Define your models like regular Objective‑C classes @interface Dog : RLMObject @property NSString *name; @property NSData   *picture; @property NSInteger age; @end @implementation Dog @end RLM_ARRAY_TYPE(Dog) @interface Person : RLMObject @property NSString             *name; @property RLMArray<Dog *><Dog> *dogs; @end @implementation Person @end  // Use them like regular Objective‑C objects Dog *mydog = [[Dog alloc] init]; mydog.name = @"Rex"; mydog.age = 1; mydog.picture = nil; // properties are nullable NSLog(@"Name of dog: %@", mydog.name);  // Query Realm for all dogs less than 2 years old RLMResults<Dog *> *puppies = [Dog objectsWhere:@"age < 2"]; puppies.count; // => 0 because no dogs have been added to the Realm yet  // Persist your data easily RLMRealm *realm = [RLMRealm defaultRealm]; [realm transactionWithBlock:^{   [realm addObject:mydog]; }];  // Queries are updated in real-time puppies.count; // => 1  // Query and update the result in another thread dispatch_async(dispatch_queue_create("background", 0), ^{   Dog *theDog = [[Dog objectsWhere:@"age == 1"] firstObject];   RLMRealm *realm = [RLMRealm defaultRealm];   [realm beginWriteTransaction];   theDog.age = 3;   [realm commitWriteTransaction]; });

// Define your models like regular Swift classes class Dog: Object {   dynamic var name = ""   dynamic var age = 0 } class Person: Object {   dynamic var name = ""   dynamic var picture: NSData? = nil // optionals supported   let dogs = List<Dog>() }  // Use them like regular Swift objects let myDog = Dog() myDog.name = "Rex" myDog.age = 1 print("name of dog: /(myDog.name)")  // Get the default Realm let realm = try! Realm()  // Query Realm for all dogs less than 2 years old let puppies = realm.objects(Dog).filter("age < 2") puppies.count // => 0 because no dogs have been added to the Realm yet  // Persist your data easily try! realm.write {   realm.add(myDog) }  // Queries are updated in real-time puppies.count // => 1  // Query and update from any thread dispatch_async(dispatch_queue_create("background", nil)) {   let realm = try! Realm()   let theDog = realm.objects(Dog).filter("age == 1").first   try! realm.write {     theDog!.age = 3   } }

// Define your models and their properties class Car {} Car.schema = {   name: 'Car',   properties: {     make:  'string',     model: 'string',     miles: 'int',   } }; class Person {} Person.schema = {   name: 'Person',   properties: {     name:    {type: 'string'},     cars:    {type: 'list', objectType: 'Car'},     picture: {type: 'data', optional: true}, // optional property   } };  // Get the default Realm with support for our objects let realm = new Realm({schema: [Car, Person]});  // Create Realm objects and write to local storage realm.write(() => {   let myCar = realm.create('Car', {     make: 'Honda',     model: 'Civic',     miles: 1000,   });   myCar.miles += 20; // Update a property value });  // Query Realm for all cars with a high mileage let cars = realm.objects('Car').filtered('miles > 1000');  // Will return a Results object with our 1 car cars.length // => 1  // Add another car realm.write(() => {   let myCar = realm.create('Car', {     make: 'Ford',     model: 'Focus',     miles: 2000,   });  // Query results are updated in real-time cars.length // => 2

// Define your models like regular C# classes public class Dog : RealmObject  {     public string Name { get; set; }     public int Age { get; set; }     public Person Owner { get; set; } }  public class Person : RealmObject  {     public string Name { get; set; }     public RealmList<Dog> Dogs { get; }  }  var realm = Realm.GetInstance();  // Use LINQ to query var puppies = realm.All<Dog>().Where(d => d.Age < 2);  puppies.Count(); // => 0 because no dogs have been added yet  // Update and persist objects with a thread-safe transaction realm.Write(() =>  {     var mydog = realm.CreateObject<Dog>();     mydog.Name = "Rex";     mydog.Age = 1; });  // Queries are updated in real-time puppies.Count(); // => 1  // LINQ query syntax works as well var oldDogs = from d in realm.All<Dog>() where d.Age > 8 select d;  // Query and update from any thread new Thread(() => {     var realm2 = Realm.GetInstance();      var theDog = realm2.All<Dog>().Where(d => d.Age == 1).First();     realm2.Write(() => theDog.Age = 3); }).Start();

Why use Realm?

Easy

Realm’s primary focus has always been ease of use. Developers tell us they switch even large apps to Realm in hours, and save weeks of implementation, optimization & debugging time on an average project.

Fast

Realm’s ease of use doesn’t come at a performance cost. Because of its memory mapping, lazy loading, and custom storage engine, Realm is usually faster than raw SQLite, despite offering a rich object-based API. Although we always recommend that everyone test their own use-cases, developers usually see huge speedups when porting apps to Realm.

Cross-platform

Realm supportsJava, Objective-C , React Native ,Swift andXamarin. You can share Realm files across platforms, use the same data models, and write similar business logic on all platforms. For debugging, .realm files can be opened with the Realm Browser .

Advanced

Realm objects are always up-to-date with the underlying data, making it trivial to follow reactive patterns or a unidirectional data flow. You can link Realm objects in graphs, use an advanced query language, rely on built-in AES256 encryption, and even easily integrate Realm data into your UI through optional add-ons.

Trusted

Have a large app or a large userbase? Realm’s the database for you. We’re already trusted in production by banks and healthcare providers, and proven across complex enterprise apps and #1 hits on both the Apple App Store and Google Play Store.

Community-driven

Realm is built in the open on GitHub. Features are prioritized based on user requests and we welcome contributions. We have over 12,000 stars on GitHub, and beyond the core projects, our community has already been building hundreds of apps, plugins & components.

Supported

Realm prioritizes support and bug fixes above all else. You can get answers about your database directly from the people that build & maintain it, via Stack Overflow , GitHub , or Twitter .

Who is using Realm?

Realm is built into apps used by over a billion people.

13,949 Commits and 6,148 Closed Issues Later: Thank You for Helping Realm Reach 1.0

Twitter

Even #1 app store successes trust Realm. Twitter’s innovative video app Vine and its 200M monthly active users started using Realm in 2016.

13,949 Commits and 6,148 Closed Issues Later: Thank You for Helping Realm Reach 1.0

Starbucks

The Fortune 500 retailer relies on Realm in their flagship app, allowing you to order ahead from your phone and reap rewards at the counter.

13,949 Commits and 6,148 Closed Issues Later: Thank You for Helping Realm Reach 1.0

Alibaba

The NYSE-listed Chinese juggernaut uses Realm in its flagship marketplace business, allowing both suppliers & buyers to sell & buy goods on a platform that generated almost $3 billion USD in revenues last year.

13,949 Commits and 6,148 Closed Issues Later: Thank You for Helping Realm Reach 1.0

Homeland Security

The U.S. Department of Homeland Security uses Realm in their Mobile Passport app — allowing you to securely enter the US with just a phone!

13,949 Commits and 6,148 Closed Issues Later: Thank You for Helping Realm Reach 1.0

Budweiser

The Global 500 giant built their innovative TapWiser app on Realm. It allows bars & stores to quickly order new kegs & bottles directly from a mobile app, since most outlets don’t have a computer on site.

13,949 Commits and 6,148 Closed Issues Later: Thank You for Helping Realm Reach 1.0

SAP

If you’re a Concur user, chances are you’ve used Realm already: expense reports & travel plans are managed in this app that serves over 20,000 clients and 30 million end-users.

13,949 Commits and 6,148 Closed Issues Later: Thank You for Helping Realm Reach 1.0

Rite Aid

The Fortune 500 retail giant trusts Realm to securely store data for customers, via the EnvisionRx program.

Other notable users include: Amazon, eBay, Google, GoPro, Walmart, Adidas, Cisco, NBCUniversal, Nike, the NFL and many, many more.

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » 13,949 Commits and 6,148 Closed Issues Later: Thank You for Helping Realm Reach 1.0

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址