dboo::odb::updated

template<class T>
obj_info* updated(T* object);                           1)
template<class T>
obj_info* updated(const std::unique_ptr<T>& object);    2)
template<class T>
obj_info* updated(const ref<T>& object);                3)
template<class FwdIterator>
void updated(FwdIterator first, FwdIterator last);      4)
commit(object)                                          1)
commit(<array of objects>)                              4)

Marks the specified objects as having been updated. The specified objects will be committing in the next call to commit_all().

1

Marks the specified object as updated.

2

Marks the object pointed to by the unique_ptr as updated.

3

Marks the object pointed to by the dboo::ref as updated.

4

Marks all objects in the provided sequence as updated.

Parameters

object

A pointer or unique_ptr to an object

first

Beginning of sequence (Forward iterator).

last

End of sequence (Forward iterator).

Return value

(none, or do not use)

Exceptions

(none)

Example

#include <dboo/rfx.h>
#include <dboo/odb.h>

class A {
public:
  inline static dboo::cls<A> cls{"A"};
  static void dboo_class_init(dboo::cls<A>& c) {
    c.member(&A::var1, "var1");
  }
private:
  int var1;
}

class B {
public:
  B() = default;
  B(A* a) : a{a} {}
  virtual ~B() = default;
  inline static dboo::cls<B> cls{"B"};
  static void dboo_class_init(dboo::cls<B>& c) {
    c.member(&A::a, "a");
  }
private:
  A* a;
}

int main() {

    dboo::odb db;

    db.connect("localhost", 8823,
              "my_database",
              "usr132",
              "password");

    auto a = new A();
    auto b = new A();
    auto c = new A();
    auto d = new A();
    auto e = new A();
    auto objA = new B(d);
    auto objB = new B(e);

    vector<A*> pbjsA = {b,c,d};
    vector<B*> pbjsB = {objA,objB};

    db.updated(a); // marks a as updated
    db.updated(objA);  // marks b, c and d as updated
    db.updated(objB);  // marks objA and objB as updated

    db.commit_all(); // commits all (including e as it
                     // is referenced from objB)

    return 0;
}
const dboo = require('dboo');
const config = require('config');

dboo.argv(process.argv);

dbConfig = config.get('dbConfig');

class UserId {
  userId = "";
  screenName = "";
  constructor(userid = "", screenName = "") {
    this.userId = userid;
    this.screenName = screenName;
  }
};

dboo.class(UserId,
  [{"userId": dboo.string},
    {"screenName": dboo.string},
  ]
);


class User {
  userId = null;
  address = "";
  constructor(userid = null, address = "") {
    this.userId = userid;
    this.screenName = screenName;
  }
};

dboo.class(User,
  [{"userId": UserId},  // referencing a UserId object
    {"address": dboo.string},
  ]
);

dboo.init(); // Class declarations must come before init!

const db = new dboo.odb();
db.connect(dbConfig.host, Number(dbConfig.port),
            dbConfig.dbName, dbConfig.webUserName,
            dbConfig.webUserPwd);

let a = new UserId();
let b = new UserId();
let c = new UserId();
let d = new UserId();
let e = new UserId();

let usrA = new User(d, "address1");
let usrB = new User(e, "address2");

let objB = [usrA, usrB];

db.updated(a); // marks a as updated
db.updated([b,c,d]]);  // marks b, c and d as updated
db.updated(objB);  // marks objA and objB as updated

db.commit_all(); // commits all (including e as it
                 // is referenced from usrB)