NoSQL in Memory DB with Persistence. [team]

posted in: AngularJS, Architecture, Design | 0

http://www.forerunnerdb.com/

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>

<p>Add some items and then refresh the page to see data-persistence in action!</p>

<script type="application/javascript" src="js/dist/jquery-2.1.3.min.js"></script>
<script type="application/javascript" src="js/dist/fdb-all.min.js"></script>
<script type="application/javascript" src="js/dist/fdb-autobind.min.js"></script>

<script type="application/javascript">
    window.db = new ForerunnerDB();
    db.collection('todo').load();
</script>

<script type="text/x-jsrender" id="todoItem">
				<li data-link="id{:_id}">
					<span>{^{:text}}</span>
				</li>
</script>

<ul id="todoList"></ul>

<form id="todoForm">
    <input id="todoText" type="text" placeholder="Enter todo item"/>
    <input type="submit" value="Add Item"/>
</form>

<script type="application/javascript">
    $('#todoForm').on('submit', function (e) {
        e.preventDefault();

        var itemText = $('#todoText').val();

        db.collection('todo').insert({
            text: itemText
        });

        db.collection('todo').save();
    });

    $('body').on('click', '#todoList li', function () {
        db.collection('todo').remove({_id: $(this).attr('id')});
        db.collection('todo').save();
    });
</script>

<script type="application/javascript">
    db.collection('todo').link('#todoList', '#todoItem');
</script>

</body>
</html>

 

Leave a Reply