realm-orm
v4.0.0
Published
[](https://app.codacy.com/gh/artis-auxilium/realm-orm/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage) [
static stringFields = ['name']
}create a new db instance with realm option (path, schema, migration, etc...) and open it
import DB from 'realm-orm'
import Person from './models/Person'
realm = new DB({
schema: [
Person
]
});
realm.open().then(() => {
// realm is ready
})insert data in database (data can be array or object). If you insert object with same primary key realm update existing object
Person.insert([{
id: 1,
name: 'second person',
age: 16,
createdAt: new Date(),
}, {
id: 2,
name: 'third person',
age: 96,
createdAt: new Date(),
}]);
get a record
person = Person.find(1)update person
person.update({ age: 10 })delete person
person.delete()
// or
Person.delete(person)query model
let oldPeople = Person.query()
.greaterThan('age', 90)
.findAll();
// results can use query
oldPeople.query()For more examples and usage, please refer to the doc.
Typescript
see person definition in test file
Stuff used to make this
- Realm-query: starting point of query builder
Release History
- 1.0.0
- initial version
Meta
Distributed under the MIT license. See LICENSE for more information.
https://github.com/artis-auxilium/realm-orm
Contributing
- Fork it (https://github.com/artis-auxilium/realm-orm/fork)
- Create your feature branch (
git checkout -b feature/fooBar) - Commit your changes (
git commit -am 'Add some fooBar') - Push to the branch (
git push origin feature/fooBar) - Create a new Pull Request
