2.1.1 • Published 8 years ago

tape-recorder v2.1.1

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
8 years ago

tape-recorder Build Status

♫♪ |̲̅̅●̲̅̅|̲̅̅=̲̅̅|̲̅̅●̲̅̅| ♫♪ Thin ORM for CouchDB on top of Nano


installation

  1. install npm
  2. npm install tape-recorder

usage

import recorder from "tape-recorder";

let UserSchema = new recorder.Schema({
  firstName: String,
  lastName: String,
  birthDate: { type: Date, default: Date.now }
});

UserSchema
    .method("age", () => {
        let now = new Date().getFullYear();
        return now - new Date(this.birthDate).getFullYear();
    })
    .virtual("fullName",
        () => { return `${this.firstName} ${this.lastName}`; },
        (value) => { [this.firstName, this.lastName] = value.split(" "); }
    );

let User = recorder.model("User", UserSchema);

let me = new User({
  firstName: "John",
  lastName: "Diggle",
  birthDate: new Date("1975/04/01")
});

me.save((error, savedMe) => {
  console.log(`Hello, I am ${savedMe.fullname}, and I'm ${savedMe.age()} years old`);
  // Hello, I am John Diggle, and I am 40 years old
});

license

copyright 2015 Benoit Charbonnier

licensed under the apache license, version 2.0 (the "license"); you may not use this file except in compliance with the license. you may obtain a copy of the license at

http://www.apache.org/licenses/LICENSE-2.0.html

unless required by applicable law or agreed to in writing, software distributed under the license is distributed on an "as is" basis, without warranties or conditions of any kind, either express or implied. see the license for the specific language governing permissions and limitations under the license.

2.1.1

8 years ago

2.1.0

8 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago